A:-Namespaces allow us to group a set of global classes, objects and/or functions under a name. To say
it somehow, they serve to split the global scope in sub-scopes known
as namespaces.
The form to use namespaces is:
namespace identifier { namespace-body }
Where identifier is any valid identifier and namespace-body is the set of classes, objects and
functions that are included within the namespace.
For example:
namespace general { int a, b; } In this case, a and b are normal variables integrated within the
general namespace. In order to access to these variables from outside the namespace we have to
use the scope operator ::. For example, to access the previous variables we would have to put:
general::a general::b
The functionality of namespaces is specially useful in case that there is a possibility that a global
object or function can have the same name than another one, causing a
redefinition error.
Q:- What is RTTI?
A:- Runtime type identification (RTTI) lets you find the dynamic type of an object when you have only a
pointer or a reference to the base type. RTTI is the official way in
standard C++ to discover the type of an object and to convert the type of a pointer or reference
(that is, dynamic typing). The need came from practical experience with
C++. RTTI replaces many homegrown versions with a solid, consistent approach.
Q:- What is a template?
A:-Templates allow to create generic functions that admit any data type as parameters and return value
without having to overload the function with all the possible data types. Until certain point they fulfill
the functionality of a macro. Its prototype is any of the two following ones:
template
function_declaration;
The only difference between both prototypes is the use of keyword class or typename, its use is
indistinct since both expressions have exactly the same meaning and behave exactly the same way.
Q:- What do you mean by inline function?
A:-The idea behind inline functions is to insert the code of a called function at the point where the
function is called. If done carefully, this can improve the application's
performance in exchange for increased compile time and possibly (but not always) an increase in the
size of the generated binary executables.
Q:-What is virtual class and friend class?
A:-Friend classes are used when two or more classes are designed to work together and need access
to each other's implementation in ways that the rest of the world
shouldn't be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class DatabaseCursor to have more privilege to the internals of class Database than main() has.
0 comments:
Post a Comment