[阅读: 703] 2004-12-17 04:16:09
Csomething
{
mytype * p;
Csomething()
{
p = (mytype * )malloc(sizeof(mytype));
....
}
mytype * getSomthing()
{ return p;
}
//void freeSomthing(mytype * p)
~Csomething()
{
free(p);
}
}
使用时能不能这样:
{
Csomething a;
printf("%s:%s",a.getSomething(),"asfsadfasdf");
//不用a.free();了吧?对象离开作用域自动释放?
}