#include <iostream>
using namespace std;
class test
{
public:
int bla(int &c);
};
int test:: bla(int &c)
{
c=100;
return c;
}
int main()
{
int c=10;
test student;
int b=1;
switch(b)
{
case '1': cout<<student.bla(c); break;
}
cout<<c;
return 0;
}
I would like to change the variable c within the switch/case-lines, but it doesn't work, probably because of a problem with the scope.
Maybe someone could help me to solve this problem? Many thanks.