在我AC.h文件:錯誤:純虛方法稱爲
#ifndef _AC_H
#define _AC_H
class AC{
private:
unsigned short PC;
public:
AC():PC(0){}
virtual ~AC(){}
virtual void test()=0;
};
#endif
在我R500.h文件:
#ifndef _R500_H
#define _R500_H
#include <iostream>
#include "AC.h"
class R500:public AC{
private: int mCStatus;
public:
R500():mCStatus(0){}
virtual ~R500(){}
void test();
};
#endif
在我R500.cpp
#include <iostream>
#include "R500.h"
using namespace std;
void R500::test(){
cout << "test called\n";
}
在我的AF.h文件
#ifndef _AF_H
#define _AF_H
#include "AC.h"
class AF{
public: int status;
AC *ac;
AF():status(1){} // this is a constructer
void menu();
void run();
};
#endif
在我AF.cpp文件:
#include <iostream>
#include "R500.h"
#include "AF.h"
#include "AC.h"
using namespace std;
void AF::menu() {
R500 r;
ac = &r;
run();
}
void AF::run() {
ac->test();
}
在我Main.cpp的
#include <iostream>
#include "AF.h"
#include "R500.h"
#include "AC.h"
using namespace std;
int main(int args, char**argv){
AF af;
af.menu();
return 0;
}
它編譯良好,但是當我運行時,它說,所謂
純虛方法
終止所謂的無一個有效的例外
Aborted
有人可以告訴我我哪裏錯了嗎? 謝謝。
發佈真實代碼。 – Erik 2011-03-25 14:32:58
我很積極,幾天前我看到這個問題,其中有不同的非真實代碼,但現在我找不到它。 – 2011-03-25 14:35:07
輸入錯誤,抱歉...我已經有AF():status(1){} //這是一個構造函數 – user676862 2011-03-25 14:46:26