程序抛出使用visual studio编译的异常,但g ++很好

时间:2016-06-09 07:15:57

标签: c++ exception multiple-inheritance

不用说了,请阅读以下代码:

------- INotifier.h -----------------------

struct INotifier
{
    virtual void do_notifier() = 0;    
    virtual ~INotifier(void);
};

------------ Notifier.h -----------------

#include "INotifier.h"
class Notifier : public virtual INotifier
{    
public:
    explicit Notifier(void);    
    virtual void do_notifier();    
    virtual ~Notifier(void);
};

----- ICommand.h ----------------

#include "INotifier.h"
struct ICommand : public virtual INotifier
{
    virtual void execute(void) = 0;
    virtual ~ICommand(void);
};

----- DelegateCommand.h -----------

#include "INotifier.h"
#include "Notifier.h"
#include "ICommand.h"

class DelegateCommand
    : public virtual ICommand
    , public virtual INotifier
    , public Notifier
{
public:
    DelegateCommand()
        : INotifier()
        , ICommand()
        , Notifier()
    {
    }

    virtual void execute()
    {
    }

    virtual ~DelegateCommand(void)
    { }
};

------ Notifier.cpp ---------

#include "INotifier.h"
#include "Notifier.h"
#include "ICommand.h"  

Notifier::Notifier(void)
    : INotifier()
{  }
void Notifier::do_notifier()  { }

Notifier::~Notifier(void)   { }

ICommand::~ICommand(void) { }
INotifier::~INotifier(void) { }

----- main.cpp中-----------

#include "DelegateCommand.h"    
int main()
{
    auto cmd = new DelegateCommand();
    return 0;
}

project file

抛出一个我从未见过的奇怪异常,我不知道如何解决它。 enter image description here

0 个答案:

没有答案