Describe
A shape class and a rectangle class are implemented in C + + and the area function is completed.
The code in the main function is given, please fill it out, and do not include the code that you have given when committing.
int main () {int W, h;while (cin>>w>>h) {shape* p = new Rectangle (w, h); Cout<<p->area () <<endl; Delete p;} return 0;}
Input
There are several groups of input data, one row per group, two positive integers per line, representing the length and width of the rectangle, respectively.
Output
Each group outputs a positive integer that represents the rectangular area.
Sample input
2 3
5 6
Sample output
6
30
#include <iostream>using namespacestd;classshape{ Public: Virtual intArea () {}};classRectangle: Publicshape{ Public: intb; Rectangle (intA=0,intb=0): A (a), B (b) {}intArea () {returnA *b; }};intMain () {intW, H; while(cin>>w>>h) {Shape* p =NewRectangle (W, h); cout<<p->area () <<Endl; Deletep; } return 0;}
"TOJ 5240" C + + Experiment: virtual function