I just have a little project that takes your name, age and a grade and than spits it back at you, but the grade is one lower than you wanted. (Ie You want an A, it gives you a B). Everything works but the grade part, I tried it with enumerations.
Why are you using pointers when you are just using a single char. You have not cleared any of the memory allocated with new creating potential memory leaks.
char * gr = newchar (temp - 1);
should be:
1 2
char *gr = newchar[1];
gr[0] = temp;
You could use
char * gr = newchar (temp);
also. Because the contents of ( ) are the value to set it to. Not how big it's suppose to be. It will also implicitly only create a 1 length char-array.
always remember to delete or delete [] any memory you allocate with new. If you don't then thats memory that will be lost when the pointer is moved or de-referenced.
char Result;
cin >> temp;
switch(temp) {
case A:
Result = 'B';
break;
case B:
Result = 'C'break;
}
That'd be the easiest way I can think of. You have to remember that when you enter 'A' into the console the computer sees that as 'A'. But when your enum is compiled the enum A no longer exists. Thats converted to 5. So You'd have to do a manual comparison, or some math comparison to check 'A' against A etc.