【发布时间】:2014-06-05 10:22:33
【问题描述】:
我正在为学校做一个项目,但我遇到了一个不知道如何解决的问题。以下是部分代码(不是整个类)和错误消息:
class CCPU
{
public:
CCPU ( uint8_t * memStart,
uint32_t pageTableRoot );
virtual ~CCPU ( void ) { }
virtual uint32_t GetMemLimit ( void ) const = 0;
virtual bool SetMemLimit ( uint32_t pages ) = 0;
virtual bool NewProcess ( void * processArg,
void (* entryPoint) ( CCPU *, void * ),
bool copyMem ) = 0;
bool ReadInt ( uint32_t address,
uint32_t & value );
bool WriteInt ( uint32_t address,
m_PageTableRoot;
};
这是从上面继承的类:
class CProcManager : public CCPU
{
public:
CProcManager( uint8_t* memStart,uint32_t pageTableRoot ) : CCPU(memStart, pageTableRoot) {}
virtual uint32_t GetMemLimit ( void ) const;
virtual bool SetMemLimit ( uint32_t pages );
virtual bool NewProcess ( void * processArg,
void (* entryPoint) ( CCPU *, void * ),
bool copyMem );
static void InitInfoPages (uint8_t * pages_mem);
};
这将是调用构造函数的代码:
CProcManager init_ccpu((uint8_t*)mem, 32/*just a test number*/);
我得到的错误信息:
solution.o: In function `CProcManager::CProcManager(unsigned char*, unsigned int)':
/home/Jan/OSY/OSY-2/solution.cpp:19: undefined reference to `vtable for CProcManager'
solution.o: In function `CProcManager::~CProcManager()':
/home/Jan/OSY/OSY-2/solution.cpp:15: undefined reference to `vtable for CProcManager'
collect2: error: ld returned 1 exit status
make: *** [test1] Error 1
CCPU 和 CProcManager 类的所有方法都已定义,我不应该更改 CCPU 类(该类在项目分配中提供)。 有人可以向我解释问题出在哪里(我猜它有定义)?
【问题讨论】:
标签: c++ inheritance methods constructor vtable