Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-10-2009
Member
 
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?
Reply With Quote
  #2  
Old 21-10-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
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.
Reply With Quote
  #3  
Old 21-10-2009
Member
 
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?
Reply With Quote
  #4  
Old 21-10-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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).
Reply With Quote
  #5  
Old 21-10-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 02:54 PM.