c++ 좌표있는 다각형 클래스 구현, 이동 복사 생성자 복사 연산자


c++ 좌표있는 다각형 클래스 구현, 이동 복사 생성자 복사 연산자

좌표가 있는 다각형 클래스를 C++로 구현한 소스코드이다. 깊은 복사가 일어나는 복사 생성자와 얕은 복사가 일어나는 이동 생성자, 그리고 각각에 대한 복사 대입 연산자도 구현되어 있다. #include <iostream> using namespace std; struct Point { int x, y; }; class Polygon { public : Polygon() { nPoints = 0; points = NULL; } Polygon(const int nPoints, const Point *points) : nPoints(nPoints) { this->points = new Point[nPoints]; for (int i = 0; i < nPoints; i++) this->points[i] = points[i]; } Polygon(const Polygon &rhs) { // 복사 생성자 nPoints = rhs.nPoints; points = new Point[nPoints];...


#C플플 #다각형클래스 #레퍼런스변수 #복사대입연산자 #복사생성자 #이동생성자 #좌표

원문링크 : c++ 좌표있는 다각형 클래스 구현, 이동 복사 생성자 복사 연산자