Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <sstream>
- using namespace std;
- class Surface {
- private:
- float width, height;
- //methods
- public:
- float getSurface() {
- return width * height;
- }
- //getter & setter
- public:
- float getWidth() {
- return width;
- }
- float getHeight() {
- return height;
- }
- void setWidth(float width) {
- this->width = width;
- }
- void setHeight(float height) {
- this->height = height;
- }
- };
- class Painting {
- private:
- float plnSqMeter;
- //getter & setter
- public:
- float getPlnSqMeter() {
- return plnSqMeter;
- }
- void setPlnSqMeter(float plnSqMeter) {
- this->plnSqMeter = plnSqMeter;
- }
- };
- class PaintedSurface : public Surface, public Painting {
- public:
- float getPrice() {
- return Surface::getSurface() * Painting::getPlnSqMeter();
- }
- };
- int main() {
- PaintedSurface ps;
- ps.setWidth(10);
- ps.setHeight(5);
- ps.setPlnSqMeter(3.9);
- cout << ps.getPrice();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment