How to overload a constructor outside of the class definition in c++ -


OK, so I'm working on a homework project and I have found a way to eliminate the homework and It will be turned on, but it is still bothering me

I have a base class which is dynamically allocating some other classes and a derived class.

  // header class base {private: type * type_price; Public: Base (); Base (type & amp; new_type); // Gestures and Setters} Category: Public Base {Private: Type 2 * Type2_ptr; Public: Derivative (); Derivative (type, type 2): base (type); }   

I have to find out that this is my Instead of doing this in the CP file, instead of doing it,

  generated (type new_type, type2 new_type2): base (new_type) {type2_ptr = new type2 (new_type2) ; };   

Edit: If I like above my I try something in CPP, I get such errors, two of them too ... Header: / * Received * / Category as you like: Public Base {Private: Type 2 * Type 2_ptr ; Public: Derivative (); Derivative (type and, type 2); }

CPP:

  base :: base (): type_pTR (null) {// implementation goes here} Base :: Base (type & Amp; new_type): type_ptr (& amp; new_type) {// implementation goes here} derived :: derivative () {// implementation goes here} derived :: Derivative (type and new type, type 2 new_type 2) : Base (new_type), type 2_peter (new) type2 (new_type2)) {// implementation goes here}   

Note new_type is reference, local Not in code In , so derived variables must be in the appropriate area!

Comments