I'm working on a program in C++ that is supposed to output som data from a couple of classes. I thought I'd let the user choose what to output (what function) through a switch in main. This is basicly how the main looks now. (Just a general overview of the class)

int main(void)
{
	char input;

	cout << "Whole lotta stuff about how to choose function" << endl;

	do
	{
		switch(input)
		{
		case '1':
			ClassName1.methodDefinedInThisClass1;
			break;
		case '2':
			ClassName1.methodDefinedInThisClass2;
			break;
		case '3':
			ClassName2.methodDefinedInThisClass1;
			break;
		case '4':
			ClassName2.methodDefinedInThisClass2;
			break;
		default:
			"Illegal option!";
			break;
		} // end switch
	} // end do
	while(input != '5');

	system("PAUSE");
	return 0;
} // end main

From this I get this error:
error C2143: syntax error : missing ';' before '.'
I'm not totally blond so I understand I'm missing a ';'. But I can't find it! I've looked through the classes, the switch, everything and I can't find it!

So my thought is that something is wrong with the switch. I haven't used this in c++ before, only Java. So there's a good possibility that I've done this wrong. Anyone got a tip?

Check in the error. It usually gives the line number to look around for mistakes. If that does not work then you can post a better overview of your program..

default:
    "Illegal option!"; // Did you forget std::cout? This obviously won't compile

techie1991: The errors happens in the ClassName.methodDefined..... lines. That's the main reason I believe this might be the wrong way to make a switch in C++. This is a school assignment so I'm trying to solve most of it my self. It's just this switch thing I can't get to work properly.

Unimportant: That's the only line in the switch that doesn't get an error. But I tried putting in a cout anyway. It didn't change anything when I tried again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.