Thread: Transfer control: GoTo?

  1. #1
    Registered User
    Join Date
    Sep 2005

    Transfer control: GoTo?

    Hello there,

    Could I implement goto to transfer control to another function in the class?


    TInt CWrUAppUi::Tick(TAny* aObject)
       goto repeat;
    void CWrUAppUi::HandleSessionEventL(...)

    If not, what are my alternatives?

    Thx in advance,

  2. #2
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    At a guess I'd say you can't do that. have you tried it? There are probably some scope issues about it.

    Could do something like this:

    class thing
    	int num;
    	thing( int new_num )
    		std::cout<< "Starting Constructor ... \n";
    		initialise( new_num );
    		std::cout<< "Ending Constructor ... \n";
    	void initialise ( int new_num )
    		std::cout<< "Starting Initialiser ... \n";
    		num = new_num;
    		std::cout<< "Ending Initialiser ... \n";
    int main( void ) 
    	thing whatever( 42 );
    	return 0;
    Very ... basic example. You can use member functions within classes. Goto's are generally a bad idea. Only real use I've had for them would be for getting out of deep nesting in loops and such. Don't use them often at all.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Place everything inside HandleSessionEventL after the repeat label into a new function. Then just call that function from HandleSessionEventL. When inside Tick, call the new function instead of the goto.

    That is just a general idea. Each specific case may have a very different solution.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. helpppp
    By The Brain in forum C Programming
    Replies: 1
    Last Post: 07-27-2005, 07:05 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Need some help with a basic tic tac toe game
    By darkshadow in forum C Programming
    Replies: 1
    Last Post: 05-12-2002, 04:21 PM