【发布时间】:2011-05-06 15:10:34
【问题描述】:
我正在尝试使用一个在类中声明枚举类型的类,如下所示:
class x {
public:
x(int);
x( const x &);
virtual ~x();
x & operator=(const x &);
virtual double operator()() const;
typedef enum {
LINEAR = 0, /// Perform linear interpolation on the table
DIPARABOLIC = 1 /// Perform parabolic interpolation on the table
} XEnumType;
};
我需要声明这个类的一个实例并初始化枚举类型。我来自 C#,通常会看到声明在类之外的枚举,而不是像这里一样的 INSIDE。如何初始化枚举类型。例如,我想做这样的事情:
x myX(10);
myX.XEnumType = Linear;
显然这不起作用。我该怎么做?
【问题讨论】: