0

I have a quick questions about redefine the type name inside the class, is it allowed in the C++ always or some compiler will accept this, others will not accept such usage.

From the describe of C++ premier 5th, chapter 7 section "Type Names Are Special", below is the snippet code from the book. from its comments cannot redefine Money, does it mean the compiler is not allowed to redefine the type name? Thanks

/*copy from the book*/
typedef double Money;
class Account {
public:
    Money balance() { return bal; }  // uses Money from the outer scope
private:
    typedef double Money; **// error: cannot redefine Money**
    Money bal;
    // ...
};
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

0 Answers0