D - RE: Odd Template Error
- resistor mac.com (8/8) Feb 25 2004 OK, I isolated that templating error down. I have a class Tree!(T). Ev...
-
Ben Hinkle
(36/36)
Feb 25 2004
wrote in message news:c1jf0l$rla$1@digitaldaemon.com.... - resistor mac.com (7/43) Feb 25 2004 Walter,
- Sark7 (6/16) Feb 26 2004 Try
OK, I isolated that templating error down. I have a class Tree!(T). Every Tree!(T) needs to have two member variables that are also Tree!(T)'s. However, if I just declare them like such: Tree!(T) left; Tree!(T) right; I get an error. What is the proper way to declare them? Owen
Feb 25 2004
<resistor mac.com> wrote in message news:c1jf0l$rla$1 digitaldaemon.com... | OK, I isolated that templating error down. I have a class Tree!(T). Every | Tree!(T) needs to have two | member variables that are also Tree!(T)'s. However, if I just declare them like | such: | | Tree!(T) left; | Tree!(T) right; | | I get an error. What is the proper way to declare them? | | Owen I think that is a compiler bug in the undocumented class-template syntax. The solution is to write class Tree(T) { Tree left; Tree right; ... } [note you leave out the !(T) in the class body] or template Tree(T) { class Tree { Tree left; Tree right; ... } } Sometimes I've wondered about using this! to refer to the template currently being defined, but that seems a little too wierd to use unless there is a good reason why other syntax choices fail. -Ben
Feb 25 2004
Walter, Would there be any chance of getting this fixed? If a templated class can create instances other templated classes as Class!(T), should it also be able create instances of itself with the same syntax? Owen In article <c1jgav$tv7$1 digitaldaemon.com>, Ben Hinkle says...<resistor mac.com> wrote in message news:c1jf0l$rla$1 digitaldaemon.com... | OK, I isolated that templating error down. I have a class Tree!(T). Every | Tree!(T) needs to have two | member variables that are also Tree!(T)'s. However, if I just declare them like | such: | | Tree!(T) left; | Tree!(T) right; | | I get an error. What is the proper way to declare them? | | Owen I think that is a compiler bug in the undocumented class-template syntax. The solution is to write class Tree(T) { Tree left; Tree right; ... } [note you leave out the !(T) in the class body] or template Tree(T) { class Tree { Tree left; Tree right; ... } } Sometimes I've wondered about using this! to refer to the template currently being defined, but that seems a little too wierd to use unless there is a good reason why other syntax choices fail. -Ben
Feb 25 2004
On Thu, 26 Feb 2004 00:35:34 +0000 (UTC), <resistor mac.com> wrote:OK, I isolated that templating error down. I have a class Tree!(T). Every Tree!(T) needs to have two member variables that are also Tree!(T)'s. However, if I just declare them like such: Tree!(T) left; Tree!(T) right; I get an error. What is the proper way to declare them? OwenTry .Tree!(T) left; .Tree!(T) right; -- Sark7
Feb 26 2004