After compilation this simple example code, I have irritating error... I don't know what's going on, can anybody help me to solve that?
File Form1.h
File Form1.cppCode:#ifndef __FORM1_H__ #define __FORM1_H__ #include "TClass.h" namespace testmycpp { public ref class Form1 { public: Form1(void); private: TClass ^m_tc; //this declaracion cause error }; } #endif
File TClass.hCode:#include "stdafx.h" #include "Form1.h" using namespace testmycpp; Form1::Form1() { }
File TClass.cppCode:#ifndef __TCLASS_H__ #define __TCLASS_H__ namespace testmycpp { public ref class TClass { public: TClass(void); }; } #endif
File stdafx.hCode:#include "stdafx.h" #include "TClass.h" using namespace testmycpp; TClass::TClass() { }
COMPILER ERROR !!Code:#pragma once
Error 1 error C2143: syntax error : missing ';' before '^'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I think you are calling that tclass wrong. It should be:
That is a strange error. I found this on MSDN: Compiler Error C2143Code:testmycpp::TClass ^m_tc; //Try this
Whenever you declare a variable of a type that is specified in a namespace such as System or std, you need to put that namespace in front of it like so:
namespace_name::variable_type
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks