AM> Could anyone explain those darn templates to me? I just started to l
AM> them and I got confused right at the start. Could anyone tell me wha
AM> wrong with the following:
About everything. The author of the template you quote doesn't know a
lot more about templates than you. If you want to store information in
a linked list, use the list template from the Standard C++ Library.
AM> template
AM> class _EXPORT TLinkedList (_EXPORT just expands to _export in a D
AM> and huge otherwise
AM> {
AM> private:
AM> TLinkedList *prev;
AM> TLinkedList *next;
AM> T *Struct;
AM> public:
AM> TLinkedList(){prev=NULL;next=NULL;Struct = new T};
AM> ~TLinkedList();
AM> BOOL Add();
AM> void Assign(T *s){hmemcpy(Struct,s,sizeof(T));};
AM> T* GetStruct(){return Struct;};
AM> TLinkedList *Next(){return next;};
AM> TLinkedList *Prev(){return prev;};
AM> };
AM> Then when I try to use that class I get more errors:
AM> class Boo
AM> {
AM> ....
AM> TLinkedList *List; <- invalid use of tamplate !?!?!
AM> };
Yes, the right way would be
TLinkedList List;
if you want to put ints into your list (and analogously for other
element types).
Use
list myList;
instead. If your library doesn't contain the list template, you can
download it from the Internet (look for STL, the Standard Template
Library).
Thomas
---
þ MM 1.0 #0113 þ Weather forecast for tonight: It's going to be dark!
---------------
* Origin: McMeier & Son BBS (2:301/138)
|