[I'd really request anyone tagging this as duplicate to read the whole question before hastily marking it as such. My question is why compilers are allowed to interpret this differently, is this an undefined or unspecified or required behavior?]
This is the code
typedef double Money;
class Account {
public:
Money balance() {
return bal;
}
private:
typedef long Money;
Money bal;
};
According to C++ Primer 5e, it is an error to redefine the same type (Money) in inner class scope.
However, it's also mentioned that some compilers may not enforce this.
Does that mean it is an undefined behavior, or unspecified behavior? If standard explicitly says that this is not allowed, how can major compilers decide not to flag this as an error?