< Previous | Contents | Next >
Q: Why do game companies use Cþþ?
A: Cþþ combines speed, low-level hardware access, and high-level constructs better than just about any other language. In addition, most game companies have a lot invested in Cþþ resources (both in reusable code and programmer experience).
Q: How is Cþþ different than C?
A: Cþþ is the next iteration of the C programming language. To gain accept- ance, Cþþ essentially retained all of C. However, Cþþ defines new ways to do things that can replace some of the traditional C mechanisms. In addition, Cþþ adds the ability to write object-oriented programs.
Q: How should I use comments?
A: To explain code that is unusual or unclear. You should not comment the obvious.
Q: What’s a programming block?
A: One or more statements surrounded by curly braces that form a single unit.
Q: What’s a compiler warning?
A: A message from your compiler stating a potential problem. A warning will not stop the compilation process.
Q: Can I ignore compiler warnings?
A: You can, but you shouldn’t. You should address the warning and fix the offending code.
Q: What is whitespace?
A: A set of non-printing characters that create space in your source files, including tabs, spaces, and newlines.
Q: What are literals?
A: Elements that represent explicit values. "Game Over!" is a string literal, while
32 and 98.6 are numeric literals.
Q: Why should I always try to initialize a new variable with a value?
A: Because the contents of an uninitialized variable could be any value—even one that doesn’t make sense for your program.
Q: Why do programmers sometimes use variable names such as myInt or
myFloat?
A: To clearly spell out a variable’s type. This convention is used frequently in programming instruction.
Q: What are variables of type bool for?
A: They can represent a condition that is true or false, such as whether a chest is locked or a playing card is face up.
38 Chapter 1 n Types, Variables, and Standard I/O: Lost Fortune
Q: How did the bool type get its name?
A: The type is named in honor of the English mathematician George Boole. Q: Must the names of constants be in uppercase letters?
A: No. Using uppercase is just an accepted practice—but one you should use because it’s what other programmers expect.
Q: How can I store more than one character with a single variable? A: With a string object.