[C ++] no corresponding function to call, expect 2 arguments 0provide

Got some error with this encoding one rectangle class, one inheritance

----------------------------------------------- --- ---------------------------

#include <iostream>
#include <cmath>
using namespace std;
class Rectangle{ //class
private:
    double width;
    double height;
public:
    Rectangle(double width, double height);
    double area();
    double circumference();
    double getWidth();
    double getHeight();
};

class SquareRectangle:public Rectangle//inheritance{
private:
     double side;
public:
     SquareRectangle(double side);
     double getSide();
};

Rectangle::Rectangle(double width, double height){
    this->width = width;
    this->height = height;
}

double Rectangle::area(){
     return (getWidth()*getHeight());
}

double Rectangle::circumference(){
     return ((getWidth()*2)+(getHeight()*2));
}

double Rectangle::getWidth(){
     return width;
}

double Rectangle:: getHeight(){
    return height;
}
SquareRectangle::SquareRectangle(double side){
    this->side = side;
}

double SquareRectangle::getSide(){
    return side;
}

      

and got this error as you can see in this screenshot Error

appreciate all the help here

+3


source to share


1 answer


The constructor for SquareRectangle must call the constructor of the parent Rectangle class . The constructor can be coded like this:



SquareRectangle::SquareRectangle(double side)
: Rectangle(side, side) {
    this->side = side;
}

      

+2


source







All Articles