C++ 如何在C++;?
我需要创建许多介于integer和enum之间的类。C++ 如何在C++;?,c++,class,enums,C++,Class,Enums,我需要创建许多介于integer和enum之间的类。 也就是说,具有整数的算术,但也不会隐式转换为int。一种可能性是使用::GetValue()方法和使用GetValue()时需要使用重载的数学运算,创建一个“枚举”定义为类的不变成员的类做有问题的数学题。看一看答案——BOOST_STRONG_TYPEDEF做的正是我想要的 // macro used to implement a strong typedef. strong typedef // guarentees that two t
也就是说,具有整数的算术,但也不会隐式转换为int。一种可能性是使用::GetValue()方法和使用GetValue()时需要使用重载的数学运算,创建一个“枚举”定义为类的不变成员的类做有问题的数学题。看一看答案——BOOST_STRONG_TYPEDEF做的正是我想要的
// macro used to implement a strong typedef. strong typedef
// guarentees that two types are distinguised even though the
// share the same underlying implementation. typedef does not create
// a new type. BOOST_STRONG_TYPEDEF(T, D) creates a new type named D
// that operates as a type T.