Thread: stack question
View Single Post
Old May 8th, 2006, 11:47 AM   #5
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 873
Rep Power: 4 The Dark is on a distinguished road
Quote:
Originally Posted by InfoGeek
You can make your driver shorter by doing something like:
		switch(mainMenuChoice)
		{
		case 1:
			Stack<int, MaxStack>* stackClassDriver = new Stack<int, MaxStack>;
			int stackItem;
			break;
                 ...
You can't declare something inside a switch statement and access it outside of the switch statement, it would then be out of scope.

To make the code shorter, you could move the repeated stuff into a template function.
The Dark is offline   Reply With Quote