The code is :
#include <iostream>
using namespace std;
class Point
{
int x, y;
public:
Point(const Point &p) { x = p.x; y = p.y; }
};
int main()
{
Point p1; // COMPILER ERROR
Point p2 = p1;
return 0;
}
The above code throws an error: COMPILER ERROR: no matching function for call to 'Point::Point()
Compiler does not create a default constructor, when we create our own copy constructor. Why?
Is this just a C++ standard rule or Is there some reason ??
EDIT: I am aware of the rule. I am just looking for the reason.