Hello experts,
I am a complete beginner in C++ (although I know C).
I am trying to compile the code below, and I get
the following error.
Can anyone explain to me my mistake?
Thanks!
PhilB
myprog2.cpp: In method `Line::Line (Point, Point)':
myprog2.cpp:32: no matching function for call to `Point::Point ()'
myprog2.cpp:12: candidates are: Point::Point (int, int)
myprog2.cpp:9: Point::Point (const Point &)
myprog2.cpp:32: no matching function for call to `Point::Point ()'
myprog2.cpp:12: candidates are: Point::Point (int, int)
myprog2.cpp:9: Point::Point (const Point &)
myprog2.cpp:32: no matching function for call to `Point::Point ()'
myprog2.cpp:12: candidates are: Point::Point (int, int)
myprog2.cpp:9: Point::Point (const Point &)
//------------------------
class Point
{
protected:
int x;
int y;
public:
Point::Point(in t, int);
};
Point::Point(in t initx, int inity)
{
x=initx;
y=inity;
return;
}
class Line:public Point
{
public:
Point start_point;
Point end_point;
public:
Line::Line(Poin t, Point);
};
Line::Line(Poin t initp1, Point initp2)
{
start_point=ini tp1;
end_point=initp 2;
return;
}
main()
{
Point p1(10,20);
Point p2(20,40);
Line l1(p1,p2);
}
//------------------------
I am a complete beginner in C++ (although I know C).
I am trying to compile the code below, and I get
the following error.
Can anyone explain to me my mistake?
Thanks!
PhilB
myprog2.cpp: In method `Line::Line (Point, Point)':
myprog2.cpp:32: no matching function for call to `Point::Point ()'
myprog2.cpp:12: candidates are: Point::Point (int, int)
myprog2.cpp:9: Point::Point (const Point &)
myprog2.cpp:32: no matching function for call to `Point::Point ()'
myprog2.cpp:12: candidates are: Point::Point (int, int)
myprog2.cpp:9: Point::Point (const Point &)
myprog2.cpp:32: no matching function for call to `Point::Point ()'
myprog2.cpp:12: candidates are: Point::Point (int, int)
myprog2.cpp:9: Point::Point (const Point &)
//------------------------
class Point
{
protected:
int x;
int y;
public:
Point::Point(in t, int);
};
Point::Point(in t initx, int inity)
{
x=initx;
y=inity;
return;
}
class Line:public Point
{
public:
Point start_point;
Point end_point;
public:
Line::Line(Poin t, Point);
};
Line::Line(Poin t initp1, Point initp2)
{
start_point=ini tp1;
end_point=initp 2;
return;
}
main()
{
Point p1(10,20);
Point p2(20,40);
Line l1(p1,p2);
}
//------------------------
Comment