struct str1
{
private:
int a;
public:
struct str2
{
public:
void func(void);
};
};
void str1::str2::func()
{
str1 obj;
obj.a=10; //this is working in GNU compiler, but according to
Bruce Eckel this should be an error
}
int main()
{
str1::str2 obj2;
obj2.func();
}
Kindly solve my doubt, this really is reported to be an error in Bruce
Eckel volume 1 but when i run this on my GNU C++ compiler this gave me
output.
Regards,
Abhishek
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I think originally it was an error, but there was a defect raised to
actually make it legal:
http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45
This was indeed an error in C++03, but the restriction was later
considered to be a bad idea and lifted.
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#45
Since it's a defect, GCC probably decided to retroactively fix it even
for its C++03 mode.
Sebastian