为什么我不能/不能在类中重新定义类型名?

Ada*_*enz 5 c++

据说a type name使用后不能在类内部定义。例如:

typedef double Money;
class Account {
public:
    Money balance() { return bal; } // uses Money from the outer
private:
    typedef double Money; // error: cannot redefine Money
    Money bal;
    // ...
};
Run Code Online (Sandbox Code Playgroud)

该程序在GCC上不起作用,但在MSVC 14上却可以正常工作!*我从“ C ++入门手册第5版”中获得了此示例。