J
Jacek Dziedzic
Hello!
Is this program syntactically correct?
// -------------------------------
template <typename T>
class Foo {
static const int len=5;
static const char ID[len];
};
template<typename T> const char Foo<T>::ID[len]={'1','2','3','4','\0'};
int main() {
Foo<double> foo;
}
// -------------------------------
It does compile with Intel's compiler, but g++ 3.3.4 reports
test3.cpp:8: error: conflicting types for `const char
Foo<T>::ID[Foo<T>::len]'
test3.cpp:5: error: previous declaration as `const char
Foo<T>::ID[Foo<T>::len]
It looks like the declarations reported are identical,
so what is it complaining about?
If the code is wrong, how can I fix it?
If the code is OK, is there a way to go around this
(apart from changing to a different compiler)?
TIA,
- J.
Is this program syntactically correct?
// -------------------------------
template <typename T>
class Foo {
static const int len=5;
static const char ID[len];
};
template<typename T> const char Foo<T>::ID[len]={'1','2','3','4','\0'};
int main() {
Foo<double> foo;
}
// -------------------------------
It does compile with Intel's compiler, but g++ 3.3.4 reports
test3.cpp:8: error: conflicting types for `const char
Foo<T>::ID[Foo<T>::len]'
test3.cpp:5: error: previous declaration as `const char
Foo<T>::ID[Foo<T>::len]
It looks like the declarations reported are identical,
so what is it complaining about?
If the code is wrong, how can I fix it?
If the code is OK, is there a way to go around this
(apart from changing to a different compiler)?
TIA,
- J.