Virtual & Pure virtual destructors

This is a discussion on Virtual & Pure virtual destructors within the C++ Programming forums, part of the General Programming Boards category; BMJ, that avatar isn't you is it? scary.....

  1. #16
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    BMJ, that avatar isn't you is it? scary..
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  2. #17
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Pure virtual is used as the base of an inheritance hierarcy so as to remove any further generalization of the hierarchy.

  3. #18
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    we all know what pure virtual is, he was asking what pure virtual destructors did for us
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #19
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    It removes any further generalization.

  5. #20
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    grr.... what??

    (this sure is fun isn't it)

  6. #21
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    meaning you can't put a base class above it?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #22
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Yeah. You can't break the implementation.

  8. #23
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I am trying to get a pure virtual destructor to compile and it won't even do that!
    Code:
    class test
         {
         public:
              test();
              virtual ~test()=0;
         };
    
    class test1 : public test
         {
         public:
              test1();
              ~test1();
         };
    
    test::test()
         {
         std::cout << "test()" << std::endl;
         }
    
    test1::test1()
         {
         std::cout << "test1()" << std::endl;
         }
    
    test1::~test1()
         {
         std::cout << "~test1()" << std::endl;
         }
    something wrong with this?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #24
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    Originally posted by FillYourBrain
    that avatar isn't you is it?
    It is now!

  10. #25
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Originally posted by FillYourBrain
    I am trying to get a pure virtual destructor to compile and it won't even do that!
    Code:
    class test
         {
         public:
              test();
              virtual ~test()=0;
         };
    something wrong with this?
    Just use:

    virtual ~test();

    And only make member functions pure virtual with the = 0; Not the destructor. Try that. Write a member function for it too.

  11. #26
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    are you saying "virtual ~test()=0" is illegal or it wont do anything?

  12. #27
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    There is no such thing as a pure virtual destructor.

  13. #28
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    It's just a virtual destructor.

  14. #29
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Originally posted by BMJ
    are you saying "virtual ~test()=0" is illegal or it wont do anything?
    I think it's illegal. I'm a Cer though not a C++er, but yeah, it's illegal.

  15. #30
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    What? Pure virtual destructors are legal; which is why I ask how and where they would be used

Page 2 of 5 FirstFirst 12345 LastLast
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. Information Regarding Pure Virtual Functions
    By shiv_tech_quest in forum C++ Programming
    Replies: 6
    Last Post: 01-29-2003, 03:43 AM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 10:14 PM
  5. virtual or pure virtual
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-01-2001, 06:19 PM

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