I have 3 classes coded in c++. They are all simple, but compiler gives alot error. Each class in a cpp file and header file. What can be the possible problems?
One of it is “base class undefined”.
class re {
int i;
int j;
string a;
re(int,int,int);
~re();
}
class Pre:public re {
int k;
public:
Pre(int,int,int);
~Pre();
}
class MPre:public Pre {
int z;
public:
MPre(int);
~Mpre(int);
}
Possible mistakes :
re class constructor is not public. Are you aware of this?
MPre constructor gets one input, so you have to write default constructor for Pre class.
Be careful when adding header files. For example, Pre class needs re class’ header file.
Also, you don’t need to write destructor unless you add pointer variables to classes