The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
call constructor of java class in script thebladerunner Shell Programming and Scripting 1 10-21-2008 12:23 PM
Linguistic Tree Constructor 2.8.0 (Default branch) iBot Software Releases - RSS News 0 01-27-2008 07:30 PM
how do you handle a constructor and destructor that fail amitpansuria High Level Programming 4 08-16-2007 02:16 PM
what is diff b/w copy constructor and overloaded assignment operator amitpansuria High Level Programming 3 08-06-2007 12:45 PM
Constructor problem woot4moo UNIX for Dummies Questions & Answers 4 09-05-2006 10:49 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-02-2007
Registered User
 

Join Date: Jul 2007
Posts: 91
why constructor cannot be virtual

helo i read many books but i cant find the proper answer that why
constructor cannot be virtual
can u explain me in simple term that why constructor cannot be virtual
Regards,
Amit
Reply With Quote
Forum Sponsor
  #2  
Old 08-02-2007
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Because some properties of a virtual function does not apply to constructor such as "run time binding", besides why would you want a virtual constructor ???
Reply With Quote
  #3  
Old 08-03-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by amitpansuria View Post
can u explain me in simple term that why constructor cannot be virtual
Virtual works by the object pointing to a v-table, and the caller dereferencing the call via the v-table. Immediately prior to construction time you don't have an object which points to a vtable to make the call.

Solutions to this include using factory objects, which is exactly what COM does with IClassFactory so the call to CreateInstance is virtual. Similarly IBM's SOMClass::somNew.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0