how do i add default in every case? it does not allow me to do it like this and will error in the second default,
switch (select)
{
case 1:
here1:
cout<<"statement"<<endl;
default:
cout<<"statement"<<endl;
goto here1;
break;
case 2:
here2:
cout<<"statement"<<endl;
default:
cout<<"statement"<<endl;
goto here2;
break;
it looks like you are trying to execute the same piece of code for every case so why can't you just do so.
default just works if "incase nothing works" and if something works default doesn't execute.
well you really cant do this because "default" considered as a case itself so you cant make two cases in one. but instead if you want so mimic it you can use an "if statement " with the condition you want.