#ifndef C_H
#define C_H
#include <memory>
class C
{
public:
C(){};
~C() {};
};
typedef auto_ptr<C> CPtr;
#endif
The above codes seem fine for me, but when I compile them with VC10, I got the following errors:
“error C2143: syntax error : missing ‘;’ before ‘<‘”. Any ideas about it will be appreciated.
#include <memory>gives youauto_ptrin thestd-namespace, so you could make this compile by replacing yourtypedefwith:Alternatively, you could introduce
auto_ptrinto the current namespace with ausingstatement, though you should really not do this in a header. To do this you would need to add a statement likeusing std::auto_ptr;orusing namespace std;.