谁能在linux下用gcc编译通过这段程序?(高手请进)
程序本身没有意义,可是在solaris下和window下都可以编译通过,在linux下却通不过,怀疑是c++的标准不同,谁可以不改程序直接在gcc中加选项编译通过?
(实在不行用最小量改程序)
#include <iostream.h>
#define SDEFINE sample i;\
i.print();
template<class TYPE>
void DestructElements(TYPE* pElements, int nCount)
{
if(!(nCount == 0 )) {
SDEFINE;
}
// call the destructor(s)
for (; nCount--; pElements++)
pElements->~TYPE();
}
class sample
{
private:
int a,b;
public:
friend class sample;
friend void sum(sample& obj);
void print();
};
void sample::print()
{
cout<<"ok"<<endl;
}
void sum(sample& obj)
{
obj.a=2;
obj.b=3;
cout<<obj.a<<endl;
}
int main()
{
sample i;
sample& j = i;
sum(j);
return 0;
}