template <class X>
class NestedTemplate { ... };
template <class A, class T>
class MainTemplate { ... };
class SampleClass {
private:
MainTemplate<NestedTemplate<char>,float> x;
public:
// methods
};
code above compiles but when running I get a "memory could not be written" error
I've tried it like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
template <class X>
class NestedTemplate { ... };
template <class A, class T>
class MainTemplate { ... };
class FakeClass { public: NestedTemplate<char> c; };
class SampleClass {
private:
MainTemplate<FakeClass,float> x;
public:
// methods
};
and it didn't work...
I can't figure out what I should change. I'm novice using templates. Simple usage described in most manuals went ok, but I got stucked here. I can solve this without templates but it'll be dirty so I would like to learn how to do it correctly.
Athar, thanks you were right in "There's no difference between template types and "normal" types"
But this is what I've found out by trying different methods of doing what I need...
The following works:
1 2 3 4 5 6 7
template<class A, class B> class FirstTemplate {...};
class SimpleClass {
private:
FirstTemplate<MyType1,MyType2> x;
// MyType1 and MyType2 are normal types, not template types, but i'm pretty sure it'll work for templates too
}