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