Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Coding Exercise
// 1. instantiate triangle class// 2. implement base function class CPolygon { protected: int width, height; string name; public: static string prefix; CPolygon(string a) { name = a; } void set_values (int a, int b) { width=a; height=b; } virtual int area () = 0;}; class CRectangle: public CPolygon { public: CRectangle(string a) : CPolygon (a) {}; int area () {return (width*height);}};string CPolygon::prefix = " area : ";main(){ CPolygon * ppoly2 = new CTriangle("tri"); CRectangle * rect = new CRectangle("rect2"); rect->set_values(8,10); rect->print_area(); ppoly2->set_values(4,5); ppoly2->print_area(); delete rect; delete ppoly2; return 0;}
run
|
edit
|
history
|
help
0
Sum Matrix Column
HexaStringToFile
Tree Node Sample
Prsonal informashin
1stoccurence
base exterior
checker
C# - a method that accepts an indefinite number of parameters
Binary Search Tree
27