Thread: all control paths don't return a value?

  1. #1
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266

    all control paths don't return a value?

    hey all, i have a warning saying that not all these paths return a value, but the inner else should just continue the loop and _not_ return a value. will this cause problems? how can i express the same thing without causing these problems?

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    some code, please?

  3. #3
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    int someFunc() {
    // complex conditional or loop
    return 0; // Never reached
    }
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  4. #4
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    christ sorry, left my head someplace else today

    Code:
    char Game::mf_game_displayOptions(int options)
    {
    	char choice='h';//local only
    	if (options==1)
    	{	bool choiceCheck=false;
    		do
    		{
    		
    		cout<<endl<<endl<<endl<<"count under con"<<"<B>unt, <L>eft grounder, <R>ight grounder, " 
    			<<"<S>acrafice fly, <H>ome run"<<endl;
    		cin>>choice;
    		choice=tolower(choice);
    		if (choice=='b' || choice=='l' || choice=='r'
    			|| choice=='s' || choice=='h')
    		{	
    			choiceCheck=true;
    			return choice;
    		}
    		else
    		{	
    			clrscr();
    			cout<<"you've entered an invalid option, please change it.";
    			choiceCheck=false;
    		}
    		}while(choiceCheck==false);
    	}
    	else
    	{return choice;}
    
    }

  5. #5
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Just get rid of the the last else it it's fine.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    char Game::mf_game_displayOptions(int options)

    my god! you really go overboard with the naming conventions!!

    dont ya think 'mf' and 'game' are a little obvious??? since the function is part of the game scope, it must be a member function of game?!

    anyways, it's not important... each to his/her own i guess

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  7. #7
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    >you really go overboard with the naming conventions!!

    i really like my system. in fact, i'm having it copyrighted
    kidding aside, i'm too much of a wuss to derive or make friend functions, so i use about a billion get functions and the names help me tell what's what in another source file.

    does anyone else have a system they like? i'd like to see it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 08:19 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM