中国开发网: 论坛: 程序员情感CBD: 贴子 65877
haitao
这个有点对象的感觉了
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();了吧?对象离开作用域自动释放?
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录