There are three classes.The first is a template, the second acts as generic for template and third implements the template.
template <class T> class Shape { T val,val_new; public: Shape(T initval) { val=initval; } ... }; class TwoPoint { int width; int value; public: TwoPoint() { value=0; width=0; } TwoPoint(int v, int w) { value=v; width=w; } TwoPoint(const TwoPoint& t) { value= t.value; width= t.width; } ... }; class Rectangle { private: Shape<TwoPoint> val; TwoPoint newval; public: Rectangle(TwoPoint i) : val (Shape<TwoPoint> (i)) {} .... }; I want to initialize the Rectangle and solidShape in some other class as class members and that can be done in java like:
Rectangle r = new Rectangle(new TwoPoint(0,8)); Shape<TwoPoint> solidShape = new Shape<TwoPoint>(new TwoPoint(0,5)); How can i do a similar type of thing in C++? I want to create an implementation like:
class C { public: // initialize Rectangle here; // initialize solidShape here; } The integer values shown here are just for illustration and can be anything.