Why won't this compile? Im using Visual C++ 6 and the error I receive has something to do with the way I declared the character array 'info' within the public section of class 'help' along with several others about the member functions and invalid overloading and all this other gibberish. thanx in advance
Code:#include <iostream> using namespace std; class help { public: char info[][50]={ "", "if(condition) statement;", "switch(expression) { //... };", "for(init;condition;iteration) { //...};", "while(condition) { //...};", "do{ //...} while(condition);", "break;", "continue;", "goto label;" }; void helpon(int query); void showmenu(); bool isvalid(int query); }; void help::helpon(int query) { cout<<info[query]<<endl; return; } void help::showmenu() { cout<<"Help on:"<<endl; cout<<"1: if"<<endl<<"2: switch"<<endl<<"3: for"<<endl<<"4: while"<<endl<<"5: do while"<<endl<<"6: break"<<endl<<"7: continue"<<endl<<"8: goto"<<endl<<"9: functions"<<endl<<"0: quit"<<endl; } void help::isvalid(int query) { if(query<0||query>9) return false; else return true; } int main() { int query; help cpp; for( ; ; ) { do { cpp.showmenu(); cin>>query; } while(cpp.isvalid(query)); if(!query) break; cpp.helpon(query); } return 0; }
Code Tags Added By Hammer



LinkBack URL
About LinkBacks


