Thursday, April 8, 2010

Some Random C++ question Which I dont want to forget

Q Global object how are the created when?

OUTPUT :
base CTOR
In main
base DTOR
------------------------------------------------------------------------
Q ) Qualifiers availabel in C++ ?
Ans : I always forget mutable , 3 qualifiers are there const ,volatile and mutable .
 What is Mutable .
 Ans :  It specifies  that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.

struct data
{
char name[80] ;
mutable int age ;
}
const data person  = { "Amit", 24 };        // Initialisation
strcpy (  person .name, "Sharma");       // compiler error
person.salaray = 2000 ;                         // Allowed since it is mutable
---------------------------------------------------------------------

Q) What problem does the namespace feature solve ?
 http://www.glenmccl.com/ns_comp.htm

1 comment:

Followers