DOH!!! Just as I thought I got everything sorted out it tells me I have an unhandled exception. Whatever that is.
Here are the classes being used
And heres the code thats causing the problem, look for the comment where the debugger says there is an unhandled exception.Code:class COption{ public: COption(const char* itsName = "",const int optNumber = 0): name(itsName),number(optNumber) {} COption(const string& itsName,const int optNumber): name(itsName),number(optNumber) {} string getName(){ return name;} int getNumber(){ return number; } private: int number; string name; }; class CMenu{ public: CMenu(const char* itsName = ""): mName(itsName) {} CMenu(const string& itsName,COption* optList): mName(itsName),o_array(optList) {} void showMenu(){ for(int i = 0; i<sizeof(o_array); i++) cout << o_array[i].getNumber() << endl; } private: string mName; COption* o_array; };
Code:/*Prototypes*/ COption* mainMenu(); int main(){ vector<int> pStack; /*Create the pegs*/ CPeg* A = new CPeg(pStack,"A"); CPeg* B = new CPeg(pStack,"B"); CPeg* C = new CPeg(pStack,"C"); /*Create menu options*/ COption* mainOpts = mainMenu(); //EXCEPTION ERROR OCCURS HERE /*Create Menus*/ CMenu* mainMenu = new CMenu("MAIN MENU",mainOpts); mainMenu->showMenu(); delete A,B,C,mainMenu; delete[] mainOpts; return 0; } COption* mainMenu(){ COption* o_array = new COption[4]; COption num1("Choose Difficulty",1); COption num2("Read rules",2); COption num3("Play game",3); COption num4("Leader board",4); COption num5("Exit",5); o_array[0] = num1; o_array[1] = num2; o_array[2] = num3; o_array[3] = num4; o_array[4] = num5; return o_array; }



LinkBack URL
About LinkBacks


