写了个小代码测试一下, g++的, 确实是即时创建和销毁的.
#include <iostream>
using namespace std;
bool myfunction (int i,int j) { return (i<j); }
struct myclass
{
myclass()
{
printf("myclass::myclass()\n");
}
~myclass()
{
printf("myclass::~myclass()\n");
}
operator int() { return a;}
int a = 5;
} ;
int main ()
{
cout << "myvector contains:"<<endl;
int retv = myclass();
cout << "mark2"<< " retv = " << retv <<endl;
return 0;
}
---------------------------------------
$ ./a
myvector contains:
myclass::myclass()
myclass::~myclass()
mark2 retv = 5
【 在 hyperLee (老李) 的大作中提到: 】
: 比如下面的代码
: struct FO
: {
: ...................
--
FROM 120.244.224.*