Publicidad
Do the following with the class Shape- Add prototypes for methods Area.docx
Do the following with the class Shape- Add prototypes for methods Area.docx
Do the following with the class Shape- Add prototypes for methods Area.docx
Próximo SlideShare
Do the following with class Shape- a- Add prototypes for all required.docxDo the following with class Shape- a- Add prototypes for all required.docx
Cargando en ... 3
1 de 3
Publicidad

Más contenido relacionado

Más de wviola(20)

Publicidad

Do the following with the class Shape- Add prototypes for methods Area.docx

  1. Do the following with the class Shape: Add prototypes for methods Area and Perimeter that will return values of template type T (these will be required methods in derived classes so write them appropriately). // 1) ******************************************************************* template <class T> class Point { public: void setX(T a) { X = a; } void setY(T b) { Y = b; } T getX() { return X; } T getY() { return Y; } private: T X; T Y; }; // 2) ******************************************************************* template <class T> class Shape { public: private: Point<T> Origin; };
  2. Solution // 1) ******************************************************************* template <class T> class Point { public: void setX(T a) { X = a; } void setY(T b) { Y = b; } T getX() { return X; } T getY() { return Y; } private: T X; T Y; }; // 2) ******************************************************************* template <class T> class Shape { public: T Perimeter(T a,T b) { return a+b; } T Area(T a,T b);
  3. { return a*b; } private: Point<T> Origin; };
Publicidad