I once thought questions like 'which part is the const variables stored in memory' was not good because we could quickly search the manual when necessary, however they are asked during the job interview, and asked twice!
So, let's just take a brief look at the frequent asked C++ interview questions. Questions about C++ can be endless as even nowadays the C++ standard is still being developed. However we'd better be familiar with those frequent questions for the sake of finding a job.
The difference between defination
and declare
:
From MSDN: Declarations introduce names in a program, for example the names of variables, namespaces, functions and classes. Declarations also specify type information as well as other characteristics of the object that is being declared. A name must be declared before it can be used; in C++ the point at which a name is declared determines whether it is visible to the compiler. You cannot refer to a function or class that is declared at some later point in the compilation unit; you can use forward declarations to get around this limitation.
Definitions specify what code or data the name describes. The compiler needs the definition in order to allocate storage space for the thing that is being declared.
Questions from this tutorial.
- What is an object?
An instance of the class is called as object.
- List the types of inheritance supported in C++.
Single, Multilevel, Multiple, Hierarchical and Hybrid. More details are given here.
- Explain the purpose of the keyword volatile.
Declaring a variable volatile directs the compiler that the variable can be changed externally. Hence avoiding compiler optimization on the variable reference.
- What is an inline function?
A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros (宏).
- Mention the storage classes names in C++.
The following are storage classes supported in C++: auto, static, extern, register and mutable. A good tutorial.