1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <stdio.h> #include "shape.h" _rectangle::_rectangle(int width, int height) { w = width; h = height; } void _rectangle::show_area() { printf("area is %d\n", w * h); } _circle::_circle(int radius) { r = radius; } void _circle::show_area() { printf("area is %d pi\n", r * r); }