When an object is created, a pointer to this vtable, called the virtual table pointer or vpointer, is added as a hidden member of this object (often the first member). The compiler also generates &quo...
When a constructor throws an exception then it means that constructor failed (duh!!) and the object is never created.Just write a simple class to test it out yourself.
Offcourse it will result memory leak.... so use auto_ptr for such thing .. see following example, i have used two types to avoid memory leaks one is auto_ptr and another is initialize function#include...
There is three query for the above question,
1) Why reference object passed as parameter to the copy constructor?
2) Why pointer object is not passed as parameter to the copy constructor?
2) What r...
Copy constructor syntax:A(const A&) for the class "A"const - Indicates object passed as argument is not changed inside copy constructor so there may be 3 design possibliti...
int iVar1; // iVar1 is never initializedint iVar2 = int(); // iVar2 will always be initialized with some initial valueThe latter should be used becaus...
Anil
May 21st, 2007
Dependsif use in main both will get initialize to '0'.ie: global if use inside a function (local) iVar1 will be garbage, iVar2 will be initialised to '0';
Dear Mohit,Sorry for late reply. I was busy doing other important tasks.You are correct,int *a = 0; won't generate any warning.and for DOS it would be 2 bytes instead of 4 for pointers without any dou...
Local variables are stored in stack - each method have a stack frame (a fixed size of memory in the stack) that is allocated for local variables each time the method is called, and deallocated when th...
Ramanuj
Oct 20th, 2012
Hi,
I have a query. The lifetime of the static variable is the entire program - if it is a local auto variable (i.e., not dynamically allocated), will it contribute to the peak memory ?
} }; int main(int c, char **v) { abc a; if(c<1) { cout<<" Error can not accept it "< exit(1); } cout<<" its in main program "< a.main();
return 0; } ">
what will be output of the following code#includeusing namespace std;class abc{ public : void main() { cout
Avaited
aparna
Oct 11th, 2006
The code mentioned would give errors while compiling. But when i have done some minor modifications to successfully compile the code, I was surprised to c that this code works fine.Later i had to come...
jayq
Sep 17th, 2006
The program you supplied has many type'o's so it will output only compile time errors.However if you fix the syntax, there'll be no controversy in this source : it ALWAYS outputs : its in main program...
Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. RTTI was added to the C++ language because many vendors of class libraries ...
Amit Mishra
Mar 21st, 2006
RTTI is a compiler was developed by microsoft with the help of visual C which work is, if we don't declared datatype to particular variable, then this compiler take defaultly the datatype of the varia...
Neither there is a concept of auto static var and Nor a auto extern varibales because auto var are local variable whose lifetime is within a block and located on stack area . Process w...
Destrcutors can be made private to stop user from creating objects on stack.
One can still create objects on stack using a static function as member function. But if intention is not to let user crea...
YESSSS destructors can be private.
Infact this concept is used in Singleton design pattern.
So, outsiders cannot delete object of that class. It has to b deleted from the class itself.
I know...I...
Program is machine code combined with data as a executable image, which is passive. If program is actively in running then its called process.
Ashwini D M
May 13th, 2016
The new process and the process representing execution of program have a many to one relationship with the program. This is called concurrent program. processes that coexist in the system at some time...
Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. RTTI was added to the C++ language because many vendors of class libraries ...
A
Jan 28th, 2006
In case of Virtual function we are responsible for deciding the function at run time. Its our logic that reflects and no one does any thing.Where as in case of RTTI TYPE is found of object. We dont do any thing for that. We simply use that.
The mutable storage class specifier is used only on a class data member to make it modifiable even though the member is part of an object declared as const.You cannot use the mutable specifier with names declared as static or const, or reference members.
Answer are correct but not perfect.The Crux is:Purpose of 'mutable' is not changing some member's values of a const object at all. (Its a side bug which comes free with functionality.)You may use muta...