[a.h]
#include <iostream>
using namespace std;

class point {
public:
 int x, y;
 point(int x, int y){cout <<\"point생성자\\n\";} // point class의 유일한 생성자
 ~point(){cout<<\"point소멸자\\n\";}
 // 중간 생략
};
class shape {
public:
 shape(int color)
 {cout << \"shape생성자\\n\";} // shape class의 유일한 생성자
 ~shape(){cout<<\"shape소멸자\\n\";}
 // 중간 생략
};
class triangle : public shape {
public:
 triangle( point p1, point p2, point p3, int color)
  : pt1( p1.x, p1.y), pt2(p2.x, p2.y), pt3(p3.x, p3.y), shape(color)
 {cout<< \"트라이앵글 생성자\\n\";}
 ~triangle(){cout<<\"triangle소멸자\\n\";}
private:
 point pt1, pt2, pt3;
};


[a.cpp]
#include \"a.h\"


int main()
{
point p1(3, 3), p2(5, 5), p3(1, 1);
triangle one(p1, p2, p3, 255);
cout <<\"=================여기까지 생성 ==================\\n\";
}



형들 내가 시험공부하다가 문제 답이 이상해서 프로그램 직접짜봤거든

근데 결과가
point생성자
point생성자
point생성자
shape생성자
point생성자
point생성자
point생성자
트라이앵글 생성자
point소멸자
point소멸자
point소멸자
=================여기까지 생성 ==================
triangle소멸자
point소멸자
point소멸자
point소멸자
shape소멸자
point소멸자
point소멸자
point소멸자
계속하려면 아무 키나 누르십시오 . . .


이렇게 나오는데 이거 왜이러지?
그러니까 처음건 위에 point p1 p2 p3를 생성하느라 세개 생성
그 다음에 shape 생성
그 다음 멤버변수 pt1 pt2 pt3를 생성한다음
트라이앵글을 생성하잖아

이렇게하면 포인트 생성자는 6개인데 왜 포인트소멸자는 9개야?;