virtual constuctor vs virtual distructor

This is a discussion on virtual constuctor vs virtual distructor within the C++ Programming forums, part of the General Programming Boards category; Hi everbody! Can anyone proper explain me the concept of virtual constructor and virtual distructor. I will be very thankful ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    18

    virtual constuctor vs virtual distructor

    Hi everbody!

    Can anyone proper explain me the concept of virtual constructor and virtual distructor.

    I will be very thankful if explained with the help of example...

    Thanks

    Bhagwat

  2. #2
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    The simplest difference is a virtual constructor doesn't exist.

    A virtual destructor does.

    In general, if your class is going to be the parent of any child class, you NEED a virtual destructor. Just put "virtual" before the destructor.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    There's technically no such thing as a virtual constructor in C++. I'd suggest reading: http://www.parashift.com/c++-faq-lit....html#faq-20.7 and the entry below it
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Virtual Box
    By ssharish2005 in forum Tech Board
    Replies: 3
    Last Post: 02-12-2009, 04:08 AM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Program with Shapes using Virtual Functions
    By goron350 in forum C++ Programming
    Replies: 12
    Last Post: 07-17-2005, 01:42 PM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 10:14 PM
  5. Exporting Object Hierarchies from a DLL
    By andy668 in forum C++ Programming
    Replies: 0
    Last Post: 10-20-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21