Thread: pure virtual calls in destructor

  1. #1
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297

    pure virtual calls in destructor

    I know that you can't call pure virtual functions in the constructor because the derived functions haven't been initialized in the table yet. But what about the destructor? I was under the impression that you could. My application throws up the "Pure virtual function call" error box when it runs. VC++ 6.0. Certainly the table still exists even though the derived class has already been destroyed. I must admit to being a bit confused about this.

    edit: I think I've found it to be "undefined" behavior. virtual calls are not supposed to ever happen in the destructor either apparently. Oh well, I'll have to restructure this.
    Last edited by FillYourBrain; 08-21-2003 at 08:18 AM.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >But what about the destructor? I was under the impression that you could.
    Not according to the standard:
    the effect of making a virtual call (10.3) to a pure virtual function directly or indirectly for the object being created (or destroyed) from such a constructor (or destructor) is undefined.
    My best code is written with the delete key.

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    so I've heard.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-28-2009, 09:25 AM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Destructors error
    By DarrenY in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2007, 04:22 AM
  4. Information Regarding Pure Virtual Functions
    By shiv_tech_quest in forum C++ Programming
    Replies: 6
    Last Post: 01-29-2003, 04:43 AM
  5. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 11:14 PM