CS 250/333: Frequently Asked Questions

Steven J. Zeil

August 16, 2013

Course Home   e-mail

This is a collection of questions (and answers!) that have arisen repeatedly in some of my past classes.

1 General Programming Questions
 1.1 I’m not sure I have a correct algorithm to solve this problem. How do I check before writing and debugging the code? (Desk-Checking)
 1.2 My program crashed. How do I find out why?
 1.3 Why do compilers’ error messages often give the wrong line number, or even the wrong file?
 1.4 What is a segmentation error? Segmentation fault? Bus error? Null reference error?
 1.5 What are formal and actual parameters?
2 The C++ Programming Language
 2.1 How do I prompt for and read keyboard input from the same line?
 2.2 What are argc and argv?
 2.3 What’s the odd expression with the ’?’ and ’:’ ?
 2.4 What are #define, #ifdef, and #ifndef?
 2.5 Why do .h files begin with #ifndef and #define?
 2.6 What is a namespace?
 2.7 What’s the difference between <string>, <string.h>, and <cstring>?
 2.8 How do I convert a string to a character array (or a character array to string)?
 2.9 How do I convert a string to a number (or a number to a string)?
 2.10 How do you tell when a string search has failed?
 2.11 What does the assert function do?
 2.12 What is ptrdiff_t?
 2.13 What is the difference between a pointer and a reference?
 2.14 Can I have 2 functions with the same name?
 2.15 What is the difference between a declaration and a definition?
 2.16 What goes in a .h file? What goes in a .cpp file?
 2.17 What is an inline function?
 2.18 Why is operator++ sometimes declared with an int parameter?
 2.19 Why do many functions come in pairs that are nearly identical except for a const?
 2.20 I have other C++ questions.
3 C++ Compilers and Error Messages
 3.1 How do I fix errors involving undeclared/undefined names?
 3.2 What should I do about the error message about "warning: … is implicitly a typename" and "warning: implicit typename is deprecated"?
 3.3 Why do I get a message about discarding qualifiers?
 3.4 How do I fix errors "No match for..."