Creating new objects in call to base class constructor from derived class

Hi,

I have a derived class SpecialCalc which inherits from base class Calc as follows:

1
2
3
4
5
6
7
8
9
10
11
12
struct Calc { 
     Calc(const someRef& thisRef) { 
       // Some code goes here
     }
};

struct SpecialCalc : Calc {
     SpecialCalc() 
     : Calc(<Don't know what to do here>) {
       // Some code goes here
     } 
}; 


When instantiating a SpecialCalc object, I want to call Calc's constructor, and create a new object at that time for a reference. I need to keep the parameter to the parent class as a const reference to a someRef object for other reasons (the example I posted is obviously abstracted). How would I create a new object in the parent constructor call and turn it into a const reference? Is this possible?

Thanks,
H.

Nevermind, figured it out.

1
2
3
4
struct SpecialCalc : Calc {
          SpecialCalc()
          : Calc(someRef()) {}
}


Topic archived. No new replies allowed.