Computer Chess Club Archives


Search

Terms

Messages

Subject: Class templates and inlining (OT)

Author: Sune Fischer

Date: 13:20:48 12/23/02


Hi, I need some help.

In order to simplify my code, I am making a small utility class (or library if
you will).

I want to do Swap, Max, Sort and all that the smart way, no macros!
For this I think a template class would be a good idea, with static functions
cause I don't have any "util" objects, so it's just a namespace container.

So far it's not quite compiling, I get this message in MSVC6.0
"error C2955: 'CUtil' : use of class template requires template argument list"

what does that mean? I did just as the book said! :) (except my function is
static)

Different question, even more serious.
How tha' heck do I inline functions in C++?

I want these Swap and Max to be inlined, I haven't figured out how to do that in
C++. The only way to inline is to write the whole function inside the header
file in the class, why is that? Isn't there a way to just have the prototype in
the class, and have the inlined function written in the cpp file?
What good is cpp files then, seems I only ever need headers???

So far I've lost 15% speed in writing from C to C++, the main problem is this
inlining issue, it's a real speed killer.

Suggestions?

-S.





This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.