What is virtual constructors/destructors?
Answers were Sorted based on User's Feedback
Answer / nk
There is nothing like virtual constructors but we can have
virtual destructors so that the destructor of the correct
object is called.
Ex.
Base *bptr = new derived()
delete bptr; then the destructor of the derived objetc is
called when the base destructor is marked as virtual.
else destructore of base class is called and may lead to
memory leak if we have allocated any new memory.
| Is This Answer Correct ? | 18 Yes | 1 No |
Answer / debasish
there is no virtual constructor..coz..virtual thing is in
run time n constructor ic compile time thing.
| Is This Answer Correct ? | 15 Yes | 3 No |
Answer / syed abdul gaffur.
CONSTRUCTOR:
Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.
DISTRUCTOR :
If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / khadeer.k
virtual constructors are used when we need to avoid the
copy same. desructor frees the memory with a ~(tilde) symbol
| Is This Answer Correct ? | 8 Yes | 9 No |
Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3
3 Answers Accenture, Cognizant, IBM,
What is the main purpose of inheritance law?
some one give d clear explanation for polymorphism
what is the need of abstraction? what is abstraction?what is the abstraction for stack?
Pls...could any one tell me that whether we can access the public data memeber of a class from another class with in the same program. Awaiting for your response Thanku
What do we mean by a hidden argument in C++?
why to use operator overloading
Why is abstraction used?
Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}
JAVA is FULLY OBJECT ORIENTED PROGRAMING LANGUAGE?
Which is the best institute in hyderabad for C/C++ and it also has fast track course structure.
design class for linked list and include constructor,destructor,insert option. struct node { int node; struct node &ptr; }