본문 바로가기
01.Bit 단기/C++

20_개체 생성과 소멸시점

by chojju 2018. 4. 30.
반응형

#include <iostream>
using namespace std;
class Stu
{
public:
 Stu() { cout << "Stu()" << endl;  }
 ~Stu() { cout << "~Stu()" << endl; }
};

void foo()
{
 Stu s;
 Stu *ps = new Stu();
 delete ps;
}

void woo()
{
// Stu s[10];
 Stu *ps[10]; //?
}

int main()
{
 cout << "foo()함수 호출 전" << endl;
// foo();
 woo();
 cout << "foo()함수 호출 후" << endl;
 return 0;
}

 

반응형

'01.Bit 단기 > C++' 카테고리의 다른 글

22_static 멤버함수  (0) 2018.05.03
21_static 멤버변수  (0) 2018.05.03
19_heap객체생성  (0) 2018.04.30
18_heap메모리 사용(C/C++ 비교)  (0) 2018.04.30
17_클래스멤버함수외부정의  (0) 2018.04.30

댓글