why constructor cannt be declar virtually?
why destructor cannt be overloaded?

Answer Posted / subhashish sen

Constructor can't be virtual,becoz constructor is an entity
which initializes V-table(V-table contains addrress of all
the virtual functions of class).So if we declare constructor
as virtual the who will intialize V-table for this constructor.

Destructor can not be overloaded simply becoz we cant
provide argument to a destructor and also its going to
release the memory when an object goes out of scope.

Is This Answer Correct ?    20 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is difference between class template and template class?

2157


what are the different types of qualifier in java?

1840


Why is polymorphism used?

583


write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.

1790


If a=5, b=6, c=7, b+=a%c*2. What is the final value of b?

943






Can we create object of interface?

601


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

1626


What is inheritance in oop?

601


Question In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Question Submitted By :: Sunil Kumar I also faced this Question!! Rank Answer Posted By Re: In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Answer # 1 use copy constructors 0 Shanthila There is something to be taken care in destructor, in copy constructor, suppose the memory is assigned to the embedded member object pointer with the parameter passed value, but if some other objects of different class also are pointing to this memory, then if some one deletes the object then this class member pointer object will become dangling, or if the object is not deleted properly then there will be memory leak. Please suggest the design change required to handle or avoid this situation

1658


What is inheritance write a program to show use of inheritance?

611


What is difference between oop and pop?

613


How to use CMutex, CSemaphore in VC++ MFC

4331


Why do while loop is used?

573


Where is pseudocode used?

563


What do you mean by abstraction?

611