The following is from a "fill-in at home" programming test that is part of the application process for an MSc in game development at a UK university:
C++ Basics
If a program declared four variables, one of type
int
, one of typefloat
, one of typechar
, and one of typebool
, which variable would occupy the least space in memory?
- int
- char
- float
- bool
According to the instructions, there is only one true statement. However, my C++ book (C++ Pocket Reference, O'Reilly) states: "The typical size of a bool is one byte," and "The size of a char is one byte. The size of a byte technically is implementation defined, but it is rarely anything but eight bits."
Am I misunderstanding something here? What answer would you put and why?