I have a class obj1 that has no default constructor, and class obj2 that also doesn’t have a default constructor, and has as private variable an element of obj1:
I would like something like the following code – but actually this doesn’t compile, telling me that obj1 has no default constructor.
class obj1{
obj1(some parameters){};
}
class obj2{
obj1 _myObj1;
obj2(some parameters){
_myObj1 = obj1(some parameters)
}
}
any ideas?
Make the constructor of
obj1public and use initialization list inobj2.