The question I'm asking appeared many times but not specific enough for mine. In my case, I have a class (lets call C0) that has a member which is a class (call this C1) which requires a constructor. However, in my case, I want to do some processing before I pass the variable into the constructor of C1. Is there a way to do this? In essence I would like to achieve something like this: (which of course doesn't work)
class C0{
public:
C0(){
ComplexDataType data;
//Do some process with data
myC1(data);
}
private:
C1 myC1;
};
class C1{
public:
C1(ComplexDataType data);
}
I've seen the initialization list from here but my only thought about how to do it would result in a VERY ugly initialization list, something like this: (which works)
class C0{
public:
C0() : variable1(doSomething1), variable2(doAnotherThing), variable3(keepItWorking), data(finallyDoSomethingWithTheOtherVariables), c1(data)
{
//Something
};
class C1{
//Stuff
};
Is there an elegant way to achieve what I desire?
Update Oh yes, I forgot to mention: I cannot change anything in class C1