When I use the scope resolution operator as part of a method declaration within a template struct, it won't work. But when I use the same scope resolution operator as part of a sizeof() within a method definition within the same template struct, it works fine. Can someone please help me to get this to work as part of a method definition? I'm using Visual C++ within Visual Studio. Here's a code sample of the problem.
sample.h
struct Top {
struct Data {
int time;
};
Data* pData;
};
template<typename T>
struct App {
T* pParent;
T::Data* getDD() { // error C2061: syntax error: identifier 'Data'
return pParent->pData;
}
int getSize() {
return sizeof(T::Data); // This works fine
}
};
sample.cpp
main() {
Top top;
App<Top> app;
Top::Data* pData = app.getDD();
int size = app.getSize();
}