Am urmatorul cod:
Code: Select all
#include <iostream>
using namespace std;
class Point
{
private:
int x, y;
public:
Point(const Point &p)
{
x = p.x;
y = p.y;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
};
int main()
{
Point p1;
Point p2 = p1;
cout << "x = " << p2.getX() << " y = " << p2.getY();
return 0;
}
Imi da eroare la compilare in linia Point p1;
La aceasta linie este declarat obiectul p1 de tipul Point.
Daca programatorul nu declara un constructor compilatorul genereaza automat un constructor implicit.
De ce imi da eroare ?