i have a problem instantiating an object, to demostrate that problem i created three files named body.cpp, head.h, head2.h
the content of the files are as follows:
body.cpp:
#include "head.h"
class2::class2()
{
myClass(5);
}
int main()
{
class2 myFinalClass();
return 0;
}
head.h:
#include "head2.h"
class class2
{
public:
class1 myClass;
class2();
};
head2.h:
class class1
{
public:
int b;
class1(int a)
{
b = a;
}
};
the problem is when i compile this compiler gives an error saying :
The data member "myClass" cannot be initialized because there is no corresponding default constructor.
what should i do? i need to declare an object on the header file of my class file then initialize that object in my constructor of the class.
Thanks