64,282
社区成员
发帖
与我相关
我的任务
分享
// scopeptr.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <boost/scoped_ptr.hpp>
class A
{
};
class B
{
public:
B::B(const A& a)
{
}
};
class C
{
public:
C::C()
{
//b1=new B(a1); syntax error
}
private:
A a1;
boost::scoped_ptr<B> b1;
//boost::scoped_ptr<B> b2(new B(b1)); syntax error
};
int _tmain(int argc, _TCHAR* argv[])
{
C c;
return 0;
}
class C
{
public:
C::C():b1(new B(a1))
{
//b1=new B(a1); syntax error
}
void Test()
{
}
private:
A a1;
boost::scoped_ptr<B> b1;
};