So im making a program the take the width and height, using 3 classes. The first to initialize the 2 variable, the second to print the value from the third class.
#include<bits/stdc++.h>
using namespace std;
class polygon
{
protected:
int width, height;
public:
polygon(int a, int b)
{
width=a;
height=b;
}
};
class output
{
public:
void print(int a)
{
cout<<a<<"\n";
}
};
class rectangle: public
polygon,public output
{
public:
rectangle (int a, int b)
{
width=a;
height=b;
}
int area()
{
return width*height;
}
};
int main()
{
rectangle rect(5,6);
rect.print(rect.area());
return 0;
}
The error message" no matching function for call to polygon:: polygon()"