我在CDrawView
课堂上有这个枚举声明:
enum shape{line, rect, elli};
在我的另一个名为 Shapemaker 的类中,我有一个函数应该从CDrawView
类中获取枚举并评估它们
Shape* Shapemaker::shapeCreate(CDrawView::shape)
{
if(CDrawView::shape.line == 0)
return new Line();
else if(CDrawView::shape.rect == 1)
return new Rect();
else if (CDrawView::shape.ellip == 2)
return new Ellip();
}
我通过调用函数Shapemaker::shapeCreate(current_shape)
wherecurrent_shape
只是enum shape
.
shape current_shape;
这给了我编译错误:
error C2653: 'CDrawView' : is not a class or namespace name
Shapemaker.h(7):
我不完全确定这是否是使用枚举和函数甚至比较枚举的正确方法。
error C2061: syntax error : identifier 'shape'
'Shapemaker::shapeCreate' : function does not take 1 arguments
CDrawView.h
class CDrawView : public CScrollWindowImpl<CDrawView>
{
public:
CDrawView();
enum shape{line, rect, elli};
shape current_shape;
//...
};
文件定义Shapemaker::shapeCreate()
在#include "CDrawView.h"
顶部。