I am trying to use a constructor that has a Struct as an argument - unsuccessfully. The TESTER constructor with the Business struct as an argument doesn't provide any members at the location in main where I create an instance of the Class. The struct Business members are available in the constructor function.
Would I have to initialize the members in the constructor "Business.CEO.id = 100" for example to make them visible in main?
struct Employee
{ short id;
int age;
double wage;
};
struct Boss
{ short id;
int age;
double wage;
};
struct Business
{ Boss CEO;
Employee HOURLY;
};
class TESTER
{
//Default Constructor
TESTER(Business Business)
{
}
};
int main() {
TESTER obj1;
TESTER obj2(obj2);
obj1. "fail no members available here"
obj2. "fail no members here either"return 0;
}
TESTER(Business Business)
The name of the var must be different from the name of the type. TESTER obj1;
Since TESTER doesn't have a default constructor you can't create an object without parameter.