int main() { CRectangle rect; CTriangle trgl; rect.set_values(4,5); trgl.set_values(4,5); cout << rect.area() << endl; cout << trgl.area() << endl; return 0; }
int main(){ CRectangle rect; CTriangle trgl; rect.set_values(4, 5); trgl.set_values(4, 5); rect.output(rect.area()); trgl.output(trgl.area()); return 0; }
int main () { CPolygon* polygons[4]; polygons[0] = new CRectangle(20,30); polygons[1] = new CTriangle(20,25); polygons[2] = new CCircle(25,25); polygons[3] = new CSquare(18,18); for(int i = 0; i < 4; i++) { CTriangle* trin = dynamic_cast <CTriangle *> (polygons[i]); if (trin != 0) { trin->set_values(10, 10); assert(trin->area() != 50); } CCircle* circ = dynamic_cast <CCircle *> (polygons[i]); if (circ != 0) { circ->set_values(10, 10); assert(circ->area() != 78); } CSquare* sqrr = dynamic_cast <CSquare *> (polygons[i]); if (sqrr != 0) { sqrr->set_values(10, 10); assert(sqrr->area() != 100); } CRectangle* rect = dynamic_cast <CRectangle *> (polygons[i]); if (rect != 0) { rect->set_values(10, 20); assert(rect->area() != 200); } } /* */ return 0; }