Hello all,
I recently came across an example of a class-qualified typedef being used like this:
Code:
#include <iostream>
using namespace std;
class X {};
typedef X* C;
template<class T> class A
{
public:
typedef int C;
typename A::C d; // <---HERE
};
int main()
{
A<X> a;
a.d = 23;
cout << a.d;
}
(It was here: Help - IBM Mac OS X Compilers)
I was a bit surprised by this, since I have never seen a class typedef being used like this before. Can a typedef be qualified in the way any other name can?
Also, is there any reason to do this other than for illustrative purposes, as in this example showing how typename is used? Given that the class typedef hides the global typedef, I'd have written C d; rather than typename A::C d;!
Thanks.