C++ copy constructor
![[C++] 복사 생성자 (copy constructor)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FcIMwgi%2FbtqzAh11oLg%2FAAAAAAAAAAAAAAAAAAAAAEcHQueRrXH1y0JpK7aqReSbhCyrugSNA0-GL3FPKxRx%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DylgW79XC4zZqj%252FYZBQsWOM%252BOcSE%253D)
[C++] 복사 생성자 (copy constructor)
1. 복사 생성자 (Copy Constructor) #include class Point { public: int x; int y; Point() : x(0), y(0) {} Point(int a, int b) : x(a), y(b) {} }; int main() { Point p1; // Point() 생성자 ok Point p2(1, 2); // Point(int a, int b) 생성자 ok Point p3(1); // Point(int a) 생성자 error Point p4(p2); // Point(Point p) 생성자 ok } 위의 코드에서 Point p4(p2); 의 경우 생성자가 없으니 error가 나야 할 것 같지만 막상 컴파일 해보면 에러 없이 정상 실행 된다. 그 말은, Point 클..