C++0x strongly typed enums
Chris Spencer
spencercw@googlemail.com
Sat Apr 18 16:31:00 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello all,
I am trying out GCC 4.4 (showing as 4.4.0_alpha20090331), and there
seems to be a problem with strongly typed enums (either with GCC, or my
interpretation).
Consider:
class myClass {
enum class foo {
fred
};
myClass() {
foo myVar = fred;
}
};
My interpretation says this shouldn't work, fred shouldn't be in scope,
but it compiles fine.
Consequently, this doesn't work:
class myClass {
enum class foo {
fred
};
enum class bar {
fred
};
};
test.cpp:7: error: declaration of âfredâ
test.cpp:3: error: conflicts with previous declaration âmyClass::foo
myClass::fredâ
Is this a GCC bug, or am I just misinterpreting the proposal?
Cheers, Chris.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknqAGAACgkQ6iqRtkAADZiBKQCgpbeMFu8eYLAMIQwJKiXmySci
exQAoOM0zcVsIQtBsdaoBAOO0JO1z0Fz
=Oiwu
-----END PGP SIGNATURE-----
More information about the Gcc-help
mailing list