Results 1 to 5 of 5

Thread: Pure virtual function call

  1. #1
    Join Date
    Jul 2009
    Posts
    81

    Pure virtual function call

    I have a message "pure virtual function call" from MSVC 7.1 in release, when in debug it does not (as the code works correctly). Here is the offending code simplified:
    Code:
    class Base
    {
    public
        Base();
        virtual void doSmth() =0;
    };
    class Ext : public Base
    {
        Ext();
        virtual void doSmth();
    };
    Base::Base()
    {
        doSmth();
    }
    Ext::Ext() : Base()
    {
    }
    void Ext::doSmth()
    {
        std::cout << "pwet";
    }
    I do not see why it crashes too. Do anyone have any idea?

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Pure virtual function call

    Your Base constructor does not make sense. Also when you build Base, Ext is not built yet, and so you have no right to call a method.

  3. #3
    Join Date
    Jul 2009
    Posts
    81

    Re: Pure virtual function call

    If that is the case then why does it work in debug? Compiling error?

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Pure virtual function call

    I see no reason for it to work in debug at your place. I tested myself your code with VC++ 9 and it crashes indeed in debug (once corrected typos and added a call through, because that base does not compile since you're not supposed to directly call a pure virtual function in constructor).

  5. #5
    Join Date
    Jul 2009
    Posts
    81

    Re: Pure virtual function call

    In my code actually Base launches a thread that calls doSmth(). I tried simplifying my code and suddenly the compiler sees it.

Similar Threads

  1. Pure Mage VS Pure Warrior in The Elder Scrolls V: Skyrim
    By Devil.King106 in forum Video Games
    Replies: 3
    Last Post: 29-11-2011, 08:58 AM
  2. Unable to call overridden virtual function
    By Kasper in forum Software Development
    Replies: 4
    Last Post: 23-02-2010, 06:38 PM
  3. How does abstract function differs from virtual function?
    By Maddox G in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 11:32 AM
  4. Winword.exe R6025 - Pure Virtual Function Call
    By Dharuna in forum MS Office Support
    Replies: 2
    Last Post: 09-06-2009, 12:27 AM
  5. Error Message #R6025 pure virtual function call
    By URmySunshine in forum Vista Help
    Replies: 1
    Last Post: 13-03-2008, 02:21 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,010,855.44894 seconds with 17 queries