Help,
I am a beginner with C++, taking a class right now. The lab this week is to create a user defined class and have it accesses in a seperate .h header file from the main.
I think I'm finding my way through it, but I'm getting a complie error that makes no sense to me:
1> Resistor.cpp
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(11): error C2146: syntax error : missing ';' before identifier 'resistor'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(14): error C2061: syntax error : identifier 'string'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(20): error C2146: syntax error : missing ';' before identifier 'getResName'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(20): warning C4183: 'getResName': missing return type; assumed to be a member function returning 'int'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(21): error C2061: syntax error : identifier 'string'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(22): error C2061: syntax error : identifier 'string'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(23): error C2061: syntax error : identifier 'string'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(29): error C2061: syntax error : identifier 'string'
1>c:\users\tom\documents\school\comp 220\week 2\lab\lab 2.2\lab 2.2\resistor.h(30): error C2065: 'res1' : undeclared identifier
//
Here is the first portion of the .h file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
/
#include <iostream>
#include <iomanip>
#include <Windows.h>
#include <math.h>
#include <string>
class CResistor {
double res1, res2, res3, percentage, Nominal, Tolerance;
bool tf;
string resistor;
public:
#include <iostream>
#include <iomanip>
#include <Windows.h>
#include <math.h>
#include <string>
class CResistor {
double res1, res2, res3, percentage, Nominal, Tolerance;
bool tf;
string resistor;
public:
/
|
Any help would be greatly appriciated!