I've got this code to port from windows to linux.
template<class T, int Size>
class CVector {
/* ... */
};
template<int n, int m>
class CTestClass {
public:
enum { Size = 1 << n };
private:
static CVector<int, Size> a; // main.cpp:19
};
template<int n, int m>
CVector<int, CTestClass<n, m>::Size> CTestClass<n, m>::a; // main.cpp:24
It compiles with VS2008, but doesn't with g++ 4.3.2. The error I receive is:
main.cpp:24: error: conflicting declaration ‘CVector CTestClass::alpha_to’
main.cpp:19: error: ‘CTestClass< n, m >::alpha_to’ has a previous declaration as ‘CVector< int, CTestClass< n, m >::Size > CTestClass< n, m >::alpha_to’
main.cpp:24: error: declaration of ‘CVector< int, CTestClass< n, m >::Size > CTestClass< n, m >::alpha_to’ outside of class is not definition
Does someone know how to make it compilable via g++?
Thanks!
This works with gcc 3.4 & 4.3 as well as VC8:
template<class T, int Size>
class CVector {
/* ... */
};
template<int n, int m>
class CTestClass {
public:
enum { Size = 1 << n };
typedef CVector<int, Size> Vector;
private:
static Vector a;
};
template<int n, int m>
typename CTestClass<n,m>::Vector CTestClass<n,m>::a;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With