2009-02-04 65 views

回答

4

看看this question的答案 - 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. 
1

一种可能性是创建一个类,该类使用:: GetValue()方法定义为具有类的不变成员的“枚举”,并且需要使用重载的数学运算来使用GetValue()来执行数学运算题。