Ok, well this is a bit wierd, but for some reason when defining a function inside a class with the identifier "string" doesn't work, I get this error
- error C2061: syntax error : identifier 'string'
here's the code
comhandle.cpp
main.cppCode:#include <string> #include "comhandle.h" void COMHANDLE::run(string mystring) { if(mystring!="test"){ bprint("you typed\""+ mystring + "\"!", true, true); } else { bprint("unknown command?", true, true); } }
comhandle.hCode:#include <stdlib.h> #include <iostream> #include <fstream> #include <string> #include "comhandle.h" COMHANDLE COMHANDLEC; // Namespaces using namespace std; // Global Functions void bprint (string text, bool cneeded, bool newline); void binit(void); void brun(void); void bprinte(void); // Globals Vars string name; string vers; string sstring; string cline; string choice; int main() { // main() Vars binit(); brun(); return 0; } void bprint (string text, bool cneeded, bool newline){ if(cneeded){ if(newline){ cout << cline << text <<"\n"; } else { cout << cline << text; } } else { if(newline){ cout << text << "\n"; } else { cout << text; } } } void binit(void) { cline = "<<: "; name = "Blade Tools v"; vers = "0.001"; sstring = name + vers; bprint(sstring, false, true); } void brun(void){ bprint("", true, false); cin >> choice; COMHANDLEC.run(choice); } void bprinte(void) { bprint ("Unknown command \""+choice+"\" - Type \"help\" for a list of valid commands.",true, true); }
main.hCode:#ifndef COMHANDLE_H #include <string> #define COMHANDLE_H class COMHANDLE { public: void run(string mystring); }; #endif
Code:#ifndef MAIN_H #define MAIN_H class MAIN { public: //to be used later } #endif
Iv tried alot of things, but have been unsuccessful in all attempts. Any help would be appreciated. Thanks!



LinkBack URL
About LinkBacks


