Computer Science Canada [C++ Help] Question about Switch-Case statement |
Author: | Shinobu [ Tue Sep 03, 2013 8:22 pm ] | ||||
Post subject: | [C++ Help] Question about Switch-Case statement | ||||
So to use a switch-case statement, it's kinda like this:
But can I insert code before the cases like this?
It would be awesome if I can; I want to deallocate the pointer I'm using for the switch-case statement. |
Author: | Dreadnought [ Tue Sep 03, 2013 11:30 pm ] |
Post subject: | Re: [C++ Help] Question about Switch-Case statement |
You can probably place code there, but it will never execute since the switch will bring you to the appropriate case, avoiding the code. I'm not sure what your doing that requires you to deallocate a pointer in the switch block but there is probably an alternative. Perhaps some more context would help? |
Author: | Shinobu [ Wed Sep 04, 2013 6:15 pm ] |
Post subject: | Re: [C++ Help] Question about Switch-Case statement |
Dreadnought @ September 3rd 2013, 11:30 pm wrote: You can probably place code there, but it will never execute since the switch will bring you to the appropriate case, avoiding the code.
I'm not sure what your doing that requires you to deallocate a pointer in the switch block but there is probably an alternative. Perhaps some more context would help? Actually, nevermind about it. I'm not going to try and save 1 byte of memory lol. Whatever XD I was just trying to delete the variable that holds what the user inputs in my program, which is used in the switch-case. |
Author: | Insectoid [ Sat Sep 07, 2013 8:03 pm ] |
Post subject: | RE:[C++ Help] Question about Switch-Case statement |
You could just delete the variable right after the switch executes. If you're not allocating anything inside the switch, then it's not saving any RAM (and even then you're probably not saving anything). |