关于抽象类的疑问
问一下抽象类的成员函数问题,我的抽象类里基本上都是虚函数,然后我定义了一个非虚函数,结果编译后出错说是这个函数不是类的成员,可是我明明在类里定义这个函数了阿,请问为什么?
贴出一部分代码:
.H文件
/*Base.h*/
#ifndef BASE_H
#define BASE_H
#include "windows.h"
class Base {
public:
//每个算法的初始化函数
virtual void Initialize() = 0;
//每个算法的Draw函数
virtual void Draw() = 0;
//设置窗口句柄
static void SetWnd(HWND hwnd) { _hwnd = hwnd; }
//设置设备句柄
static void SetDC(HDC hdc) { _hdc = hdc; }
//得到设备句柄
static HDC getDC() { return _hdc; }
//得到窗口句柄
static HWND getWND() { return _hwnd; }
//重绘函数
static void redraw() {
RedrawWindow(_hwnd, NULL, NULL,RDW_INTERNALPAINT | RDW_INVALIDATE );
//设置字体函数
void SetFont(HDC hdc);
}
private:
static HDC _hdc; //设备句柄
static HWND _hwnd; //窗口句柄
};
#endif
.CPP文件
/*Base.cpp*/
#include "Base.h"
HWND Base::_hwnd = 0;
HDC Base::_hdc = 0;
void Base::SetFont(HDC hdc) {
HFONT hFont;
HFONT hOldFont;
LOGFONT logfont;
//初始化logfont各个元素
memset(&logfont, 0, sizeof(logfont));
//确定字库的字符平均宽度,高度
logfont.lfHeight = 50;
logfont.lfWeight = 70;
logfont.lfWidth = 30;
logfont.lfUnderline = TRUE;
////创建一种逻辑字库
hFont = CreateFontIndirect(&logfont);
hOldFont = (HFONT)SelectObject(hdc, hFont);
}