A: The traditional C++ (pre-standard) headers define classes, values, macros, and functions in headers that have *.h extension. This includes non-standard STL headers with *.h extension (iostream.h, fstream.h, vector.h, etc.) and C headers with *.h extension (stdlib.h, stdio.h, etc.). Pre-standard headers have all the code in the global namespace.
A: C++ standard headers are those headers that are specified by the C++ standard.
A: The naming scheme for these files were specified based on the naming scheme of the traditional header files, but without the ending '.h'. For example, 'fstream.h' becomes 'fstream', 'memory.h' becomes 'memory' and so on.
A: The header iostream.h has never been part of the official C++ standard, which means any compiler that provides iostream.h, can do what ever it wants with it, and the compiler would still be considered compliant with the C++ standard.
A: The traditional ANSI C standard header files are prefixed with the letter 'c'. Thus 'stdio.h' has become 'cstdio', 'stdlib.h' is called 'cstdlib', 'math.h' is called 'cmath', 'time.h' is called 'ctime' and so on.
A: Assignment and comparison are not necessarily related, but we decided to handle them together because the mistakes made by programmers beginning with C++ have a common root, that is, the tendence to use a 'natural' syntax.
This actually is an issue only when working with C-style strings, i.e. 'char*'. The most common mistake is this:
char *s1, *s2;
s2 = s1; //might not do what one would think
Another mistake that is frequently made by beginners is something like this:
char* s = "Hello";
s = 'a'; // attempting to change the 'e' to an 'a'
A: If you declare a class in your code the compiler normally needs to know some information about the used class like e.g. size. But if you just uses a pointer or a reference, the compiler doesn't need to know those information at that point since pointers or references are always the same size (4 bytes on a windows system). So you just need to tell the compiler that there will be a class - in this case called 'CSomeClass' - which will be used later by that declared pointer or reference.
In this case you can use the so-called 'forward declaration'...
A: Whenever you allocate memory with 'new', you have to free the memory using 'delete'. When you allocate memory with 'new', then use 'delete' without the brackets. You use 'new' to allocate an array of values (always starting at the index 0).
int *pi = new int; // allocates a single integer
int *pi_array = new int; // allocates an array of 10 integers
pi = 0;
delete  pi_array;
pi_array = 0;
A: Because such a large piece of memory exceeds the stack size (a stack overflow). You need to allocate the memory on the heap instead:
double* x = new double;
A: Design Patterns represent solutions to problems what arise when developing software within a particular context.
A: Basically, there are three categories:
• Creational Patterns: deal with initializing and configuring classes and objects
• Structural Patterns: deal with decoupling the interface and implementation of classes and objects
• Behavioral Patterns: deal with dynamic interactions among societies of classes and objects
A: Answer is that if precision is less of a concern than storage, consider using type float for floating-point variables. Conversely, if precision is the most important criterion, use type double.
A: A random number generator needs to be seeded before use, or it will always generate the same list of random numbers. For example the C 'time()' function can be used for this: