#include <iostream>
using namespace std;
class rectangle
{
protected:
int width,height;
public:
rectangle(int, int );
void input(istream &input);
int area();
};
class square:public rectangle
{
public:
square(int a=0);
void input(istream &indev);
};
rectangle::rectangle(int a,int b)
{
height=a;
width=b;
}
void rectangle::input(istream &indev)
{
indev>>width>>height;
}
int rectangle:: area()
{
return width*height;
}
square::square(int a)
{
width=height=a;
}
void square::input(istream& indev)
{
indev>>width;
height=width;
}
int main()
{
rectangle a;
square b;
a.input(cin);
cout<<a.area()<<endl;
b.input(cin);
cout<<b.area()<<endl;
}
Đây là lỗi khi mình build:
||=== Build: Debug in singleton (compiler: GNU GCC Compiler) ===|
Power of Chaos Common\singleton\main.cpp||In constructor 'square::square(int)':|
Power of Chaos Common\singleton\main.cpp|32|error: no matching function for call to 'rectangle::rectangle()'|
Power of Chaos Common\singleton\main.cpp|19|note: candidate: rectangle::rectangle(int, int)|
Power of Chaos Common\singleton\main.cpp|19|note: candidate expects 2 arguments, 0 provided|
Power of Chaos Common\singleton\main.cpp|3|note: candidate: rectangle::rectangle(const rectangle&)|
Power of Chaos Common\singleton\main.cpp|3|note: candidate expects 1 argument, 0 provided|
Power of Chaos Common\singleton\main.cpp||In function 'int main()':|
Power of Chaos Common\singleton\main.cpp|43|error: no matching function for call to 'rectangle::rectangle()'|
Power of Chaos Common\singleton\main.cpp|19|note: candidate: rectangle::rectangle(int, int)|
Power of Chaos Common\singleton\main.cpp|19|note: candidate expects 2 arguments, 0 provided|
Power of Chaos Common\singleton\main.cpp|3|note: candidate: rectangle::rectangle(const rectangle&)|
Power of Chaos Common\singleton\main.cpp|3|note: candidate expects 1 argument, 0 provided|
Power of Chaos Common\singleton\main.cpp|44|error: no matching function for call to 'square::square()'|
Power of Chaos Common\singleton\main.cpp|32|note: candidate: square::square(int)|
Power of Chaos Common\singleton\main.cpp|32|note: candidate expects 1 argument, 0 provided|
Power of Chaos Common\singleton\main.cpp|13|note: candidate: square::square(const square&)|
Power of Chaos Common\singleton\main.cpp|13|note: candidate expects 1 argument, 0 provided|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Bạn nào chỉ cho mình lỗi mình mắc phải?