Class constructor with struct as argument

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?

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
29
30
31
32
33
34
35

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.
Topic archived. No new replies allowed.