'function-style cast' : 作为操作员右侧'.'非法

'function-style cast' : illegal as right side of '.' operator

本文关键字:非法 操作员 function-style cast      更新时间:2023-10-16

我已经在我的drawview类中声明了一个enum:

enum current_shape{line,rect,elli};

在我的主类中,我有一个名为m_viewdrawview实例。

我尝试这样设置枚举:

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;

m_view.current_shape一个不同的名字,current_shape在声明后保留为enum类型