c api *grrrr* in c++ klasse integrieren (funktion aus api mit pointer funktion parameter)



  • erstmal:

    mgWalk parst hirarchy in einem file u führt bei jedem punkt in hirarchy &c_fltBase::Check aus....

    datentypen aus api:
    mgrec * (ist struct)
    mgbool (bool mit MG_TRUE/MG_FALSE)

    //c_fltBase.h
    
    class c_fltBase
    {
    	 char *output;
    	 mgrec *lodnode;
    
    	public:
    		static char *charlodname;
    		vector<string> alllods;
    
    		//c_fltBase();
    
    		//~c_fltBase();
    
    		static mgbool Check (mgrec *startingnode, mgrec *parent, mgrec *currentnode, void *output)
    		{
    			mgcode nodetype = mgGetCode(currentnode);
    			if (nodetype == fltLod)
    			{
    				charlodname;
    				string strlodname = static_cast<string> (charlodname);
    			}
    			return (MG_TRUE);
    		}
    
    		void FindAllLODs (mgrec *&base,  std::vector<std::string *> &lodresults)
    		{
    			mgWalk (base,  :mad: &c_fltBase::Check  :mad: , MG_NULL, output, (MWALK_NEXT, MWALK_NORDONLY));			
    		}
    
    };
    
    //main.cpp
    
    void main ()
    {
    	mgrec * db;
    
    	c_fltBase test;
    
    	vector<string *> stringTest;
    
    	test.FindAllLODs(db, stringTest);   //wenn ich die zeile ausklammere dann kein error
    }
    

    vs 2005 compiler:

    1>Compiling...
    1>main.cpp
    1>Linking...
    1>main.obj : error LNK2001: unresolved external symbol "public: static char * c_fltBase::charlodname" (?charlodname@c_fltBase@@2PADA)
    1>.\/fdelpolyd.exe : fatal error LNK1120: 1 unresolved externals

    wär super wenn mir jem. helfen könnte bin schon ziemlich am verzweifel 😞 😕

    danke im vorhinein
    🙂



  • // c_fltBase.cpp
    char* c_fltBase::charoldname;
    


  • nö is auch nicht dann gibts:

    1>Compiling...
    1>main.cpp
    1>d:\nik\code\fedlpoly2\c_fltBase.h(33) : error C2597: illegal reference to non-static member 'c_fltBase::charlodname'
    1>d:\nik\code\fedlpoly2\c_fltBase.h(34) : error C2597: illegal reference to non-static member 'c_fltBase::charlodname'
    1>d:\nik\code\fedlpoly2\c_fltBase.h(34) : fatal error C1903: unable to recover from previous error(s); stopping compilation



  • Hast du auch die c_fltBast.h includiert?



  • also habs zuerst im header probiert.... sry

    im .cpp meint der compiler:

    1>Compiling...
    1>main.cpp
    1>d:\nik\code\fedlpoly2\c_fltBase.h(32) : error C2065: 'charlodname' : undeclared identifier
    1>c_fltBase.cpp
    1>d:\nik\code\fedlpoly2\c_fltBase.h(32) : error C2065: 'charlodname' : undeclared identifier
    1>.\c_fltBase.cpp(5) : error C2039: 'charlodname' : is not a member of 'c_fltBase'
    1> d:\nik\code\fedlpoly2\c_fltBase.h(13) : see declaration of 'c_fltBase'
    1>.\c_fltBase.cpp(5) : error C2040: 'charlodname' : 'char *' differs in levels of indirection from ''unknown-type''
    1>Generating Code...
    1>Build log was saved at "file://d:\nik\code\fedlpoly2\Debug\BuildLog.htm"



  • ja hab ich gemacht



  • ah sry hab bockmist gebaut 🤡

    funktioniert 😮 😮
    vielen dank 🙂 😃



  • könnt ma vl noch jem erklähren wiso ich im cpp file redeklarieren muss?



  • FranticallyNewbe schrieb:

    könnt ma vl noch jem erklähren wiso ich im cpp file redeklarieren muss?

    NIcht deklarieren tust du im cpp file, sondern definieren!




Anmelden zum Antworten