Hi all. I've stripped down my problem code but preserved my structure, which is why the code below looks meaningless, but can someone please tell me why the commented-out line generates the GCC error
expected `;' before "iter" but the corresponding line in test.cpp does not?
First, PT.hpp:
namespace T {
template<unsigned int NUM, typename DATA>
class PT {
int x;
// Stuff
public:
class iterator {
int x;
// stuff;
};
};
}
and D.hpp:
#include "PT.hpp"
namespace T {
template<typename DAT>
class D {
private:
static const unsigned int NUM = 3;
class DT {
int x;
DAT d;
// stuff
};
typedef PT<NUM, DT> X;
X x;
// X::iterator iter;
// The above line gives an error.
};
}
and test.cpp:
#include "D.hpp"
typedef T::PT<3, int> Type;
int main(){
Type t;
Type::iterator i; // THIS LINE COMPILES FINE
}
The files as they are above will compile, as soon as I un-comment the line in D.hpp it errors. I don't understand how they're different.
(Excuse the odd names.)