Thread: Unhandled exception

  1. #1
    Registered User
    Join Date
    Mar 2002

    Unhandled exception

    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
    class COption{
    	COption(const char* itsName = "",const int optNumber = 0):
    	COption(const string& itsName,const int optNumber):
    	string getName(){ return name;}
    	int getNumber(){ return number; }
    	int number;
    	string name;
    class CMenu{
    	CMenu(const char* itsName = ""):
    	CMenu(const string& itsName,COption* optList):
    	void showMenu(){
    		for(int i = 0; i<sizeof(o_array); i++)
    			cout << o_array[i].getNumber() << endl;
    	string mName;
    	COption* o_array;
    And heres the code thats causing the problem, look for the comment where the debugger says there is an unhandled exception.

    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);
    	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;
    Last edited by pdstatha; 06-22-2002 at 10:34 AM. - Portfolio site

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    You create an array of 4 COption's then try and assign to 5 of them in your mainMenu() function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-11-2006, 06:46 PM
  2. I got an unhandled exception!!
    By LegendBreath in forum Game Programming
    Replies: 7
    Last Post: 04-19-2005, 01:55 PM
  3. Unhandled exception: User breakpoint
    By glUser3f in forum C++ Programming
    Replies: 3
    Last Post: 10-02-2003, 04:20 PM
  4. unhandled exception error
    By trends in forum C++ Programming
    Replies: 4
    Last Post: 11-15-2002, 06:54 PM
  5. Unhandled Exception
    By StringQuartet13 in forum C++ Programming
    Replies: 1
    Last Post: 03-04-2002, 05:18 PM