64,651
社区成员
发帖
与我相关
我的任务
分享
FKey *a = getKey(seed);
FKey *getKey(typename seed)
{
int value = func(seed);
FKey * temp = new FKey;
temp -> key1 = value;
return temp;
}
FKey *getKey((char *) &p)
{
int value = func(seed);
p = NULL;
p = new FKey;
}
你可以试一下这种方式,把指针作为引用传递进去,还有和六楼说的一样,如果要求高的话,需要安全指针吧,auto_ptr, shared_ptr
还有boost里面的,总之,需要自己要控制资源管理器,虽然我现在和你做的也差不多,也是这种方法,不过我的都是小demo了