1 solutions
-
0
C++ :
#include <iostream> using namespace std; class Rectangle { public: Rectangle(double l, double w); Rectangle() {} double CalArea(); protected: double length; double width; }; class Rectangular:public Rectangle { public: Rectangular(double l, double w, double h); double CalVolume(); private: double height; }; Rectangle::Rectangle(double l, double w) { length = l; width = w; } Rectangular::Rectangular(double l, double w, double h):Rectangle(l,w),height(h) {} double Rectangle::CalArea() { return length*width; } double Rectangular::CalVolume() { return height*width*length; } int main() { double l,w,h; cin>>l>>w; Rectangle rectangle(l,w); cout<<rectangle.CalArea()<<endl; cin>>l>>w>>h; Rectangular rectangular(l, w, h); cout<<rectangular.CalVolume()<<endl; return 0; }
- 1
Information
- ID
- 17026
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By