sorry to bother again, but I am a lit surprised that I got no answer on my
post (attached below).
So I refined the code a little bit :-).
If there is a typedefed class X inside a class Y which has the same typedef
name and used in the form "Instance_Y::ty pe::type" MSVC7.1 fails to compile.
See example below.
It looks like a kind of name-hiding, which I do not understand in this
context. In my opinion it should not be here (ok, i am not very good in
interpreting the standard).
If I posted in the wrong newsgroup, please tell me where I should post.
Regards,
Patrick
// ***** CODE START ******
#include <iostream>
template <typename T>
struct A_bar {
typedef T A_type;
typedef T A_value;
};
template <typename T>
struct B_bar {
typedef T B_type;
typedef T B_value;
};
template <typename T>
struct B_bar2 {
typedef T B_type;
typedef T B_value;
};
int main()
{
B_bar< A_bar<double> >::B_type::A_va lue x1;
B_bar< A_bar<double> >::B_type::A_ty pe x2;
B_bar< B_bar<double> >::B_type::B_va lue y1;
// B_bar< B_bar<double> >::B_type::B_ty pe y2; // this line causes errors
in MSVC 7.1
// test6.cpp(29) : error C2146: syntax error : missing ';' before
identifier 'y2'
// test6.cpp(29) : warning C4551: function call missing argument list
// test6.cpp(29) : error C2065: 'y2' : undeclared identifier
// but there is a small work-around
typedef B_bar< B_bar<double> >::B_type dummy_type_B;
dummy_type_B::B _type y3;
B_bar< B_bar2<double> >::B_type::B_va lue z1;
// B_bar< B_bar2<double> >::B_type::B_ty pe z2; // same errors & warnings
// test6.cpp(34) : error C2146: syntax error : missing ';' before
identifier 'z2'
// test6.cpp(34) : warning C4551: function call missing argument list
// test6.cpp(34) : error C2065: 'z2' : undeclared identifier
// but there is the same workaround
typedef B_bar< B_bar2<double> >::B_type dummy_type_B2;
dummy_type_B2:: B_type z3;
}
// ***** CODE END ******
"Patrick Kowalzick" <Pa************ ***@cern.ch> wrote in message
news:e0******** ******@TK2MSFTN GP10.phx.gbl...
Dear NG,
In thought the following program should compile without errors. Is there a
reason why it is not compiling ?
Thanks,
Patrick
#include <iostream>
template <typename T>
struct A_bar {
typedef T A_type;
};
template <typename T>
struct B_bar {
typedef T B_type;
};
int main()
{
B_bar< A_bar<double> >::B_type::A_ty pe x;
B_bar< B_bar<double> >::B_type::B_ty pe x; // this line causes Error in
MSVC 7.1
// test6.cpp(18) : error C2146: syntax error : missing ';' before
identifier 'x'
// test6.cpp(18) : warning C4551: function call missing argument list
}