think i've got it.  i had those function definitions inside the class
definition.  now that i applied the template to the entire class (which is
probably a better design idea anyway), it seems to work (with a little more
playing, that is).  thanks to NIN and a quick run through some quake1.

barret

----- Original Message -----
From: "Barret Rhoden" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 6:10 PM
Subject: [hlcoders] C++ Template Question


> hi -
>
> i'm repeating a post of mine from thewavelength's forums regarding
> templates.  anyone have any advice?
>
> i've tried a few different things, here's the definitions for them:
>
> CODE
>
>      template <class T> void Test2(void) { T damn; return; }; //default
with
> int
>      template <class T> T Test(T a, T b) { return (a>b?a:b); }; // used
> ints, avoided <>
>      template <class T> T* CreateMinElements(T* a); // same as in cbase.h
> GetClassPtr
>      template <class T> void ResetSystem(void); // default example
>
>
>
> and called them like such:
>
> CODE
>
>      Test2<int>();
>      Test(3,5);
>
>      CTempElement* a;
>      a = CreateMinElements((CTempElement*) NULL);
>
>      ResetSystem<CGenericListElement>();
>
>
>
> and got the following errors on compile:
>
> QUOTE
>
> --------------------Configuration: hl - Win32 Profile--------------------
> Compiling...
> zillion_lists.cpp
> D:\dev\sdk2-3\Single-Player Source\dlls\zillion_lists.cpp(255) : error
> C2062: type 'int' unexpected
> D:\dev\sdk2-3\Single-Player Source\dlls\zillion_lists.cpp(258) : error
> C2893: Failed to specialize function template 'T *__thiscall
> CGenericSystem::CreateMinElements(T *)'
>        With the following template arguments:
>        'class CTempElement'
> D:\dev\sdk2-3\Single-Player Source\dlls\zillion_lists.cpp(259) : error
> C2275: 'CGenericListElement' : illegal use of this type as an expression
>        D:\dev\sdk2-3\Single-Player Source\dlls\zillion_lists.h(24) : see
> declaration of 'CGenericListElement'
> D:\dev\sdk2-3\Single-Player Source\dlls\zillion_lists.cpp(259) : error
> C2059: syntax error : ')'
> Error executing cl.exe.
>
> hl.dll - 4 error(s), 0 warning(s)
>
>
>
>
> any ideas? i did in fact implement the bodies of the first two, but i
don't
> think it's important enough to include here. CGenericListElement is a
parent
> of CTempElement, and the two templates that have those as the parameters
> imply the use of the parent type or something related, due to some
internal
> commands with T.
>
> thanks,
>
> barret
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to