سؤال

Is is possible to redefine 'break' in such a way that I can just write 'torsk' instead? E.g:

switch (chocolateistasty) {

    case true: {
        cout << "It is!" << endl;
        torsk;
    }
    case false: {
        cout << "Nope." << endl;
        torsk;
    }
}

I imagine this would be done with some preprocessor commands.

هل كانت مفيدة؟

المحلول

#define torsk break

but I also wonder why would you want such weird thing...

نصائح أخرى

Yes you can do it with preprocessor

#define torsk break

you can do anything you want like

#define forever for(;;)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top