PDA

View Full Version : Constructor คืออะไรครับใน C++



Anonymous
18-11-2004, 11:36 PM
พึ่งหัดเขียนครีบ

asylu3
20-11-2004, 07:48 PM
Constructer คือ ส่วนหนึ่งของ Class ที่จะถูกเรียกโดยอัตโนมัติหลังจากที่สร้าง object


#include < iostream.h >

class obj
{
public:
obj()
{
cout<<" obj created.n";
}

~obj()
{
cout<<" obj destroyed.n";
}



};


int main()
{

obj a =new obj();
return 0;
}



output

obj created
obj destroyed