Errors using the same identifier as type and function name | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
Hi, I wonder why the following code gives the error below with
gcc-3.4.6 up to 4.3.1 (I don't know about earlier versions):
struct type {};
struct A
{
type *type() { return 0; }
};
teste.cpp:5: error: declaration of 'type* A::type()'
teste.cpp:1: error: changes meaning of 'type' from 'struct type'
If we define 'A' as
struct A : type
{
type *type() { return 0; }
};
it compiles fine.
I've searched the C++2003 standard for something related to this but
couldn't find anything. Anyone knows what's happening here?
IMHO it should compile because 'A::type' is in a different scope of 'struct type', and the fact that we're referencing 'struct type' *before* specifying 'A::type' function name shouldn't make both identifiers ambiguous.
Regards, Rodolfo Lima
[Linux C Programming] [C Programming] [Kernel List] [eCos] [Fedora Development] [Fedora Announce] [Autoconf] [The DWARVES Debugging Tools] [Yosemite Campsites] [Yosemite News] [Linux GCC] [C++ How to Program]