|
Hi all,
I am having trouble with class definition with template. The following is a simple example:
template <class DataType>
struct TestStruct {
DataType key;
};
template <class s, class d>
class DummyClass {
public:
d getKey(s<d> *var) {
return var->key = 10;
}
};
int main() {
DummyClass<TestStruct, double> myClas;
return 0;
}
|
|
It produces an error because of s<d>.
If I write:
template <class DataType>
struct TestStruct {
DataType key;
};
template <class s, class d>
class DummyClass {
public:
d getKey(s *var) {
return var->key = 10;
}
};
int main() {
DummyClass<TestStruct<double>, double> myClas;
return 0;
}
|
|
It works just fine. But that is not I want because I need to use "double" twice. Can anyone help?
|
|
|
what do you mean u need to use double twice??
s<d> is wrong that is why it's no working
|
|
|
|
|
|
|
// |