我在我的 drawview
类中声明了一个枚举:
enum current_shape{line,rect,elli};
在我的主类中,我有一个名为 m_view
的 drawview
实例。
我尝试通过以下方式设置枚举:
m_view.current_shape = line;
我也试过
m_view.current_shape = m_view.line;
如何正确设置此enum
?
最佳答案
枚举是一种类型。您的枚举类型称为 current_shape
。现在您需要一个该类型的对象。但是,可能应该更改名称,以便对象为 current_shape
并且枚举为 shape
:
enum shape { line, rect, elli };
shape current_shape;
现在您可以像这样设置您的current_shape
:
m_view.current_shape = drawview::line;
关于c++ - '函数式转换' : illegal as right side of '.' operator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15690249/