I have 2 classes : point
and droite
.
Header file for Point:
class point
{
int abs,ord;
public:
point(int,int);
~point();
};
cpp file for Point
point::point(int a,int b):abs(a),ord(b)
{
cout<<"++ constructor point "<<abs<<" "<<ord<<endl;
}
point::~point()
{
cout<<"-- destruction abs= "<<abs<<"et ord= "<<ord<<endl;
}
Header file for Droite:
class droite: public point{
point s1;
point s2;
public:
droite(int,int,int,int);
~droite();
};
cpp file for Droite
droite::droite(int a,int b,int c,int d):s1(a,b),s2(c,d)
{
cout<<"++ constructor of droite "<<a<<""<<b<<""<<c<<""<<d<<endl;
}
droite::~droite(){ cout<<"destructor of droite "<<endl;}
And main
int main(){
droite A(1,2,3,4);
}
The ouput is :
droite.cpp|12| error: no matching function for call to 'point::point()'
My question is: why am I getting this error while there's a constructor with arguments for point?
This looks like a syntax error. I'm not sure why you are redeclaring public point
in your droite header file.
class droite: public point{
point s1;
point s2;
public:
droite(int,int,int,int);
~droite();
};