>I am required to add functions on the Log class
If you want them to be treated polymorphically, yes. But templates can't be virtual, and writeLog is best written as a template. Annoying little impasse, isn't it? :) Whatever will you do? How about moving the template up a level, to a template class at Log and MultiLog instead of template functions within Log? Then you can make writeLog virtual and still have the template parameter Generic from the class template to work with. This offers both the behavioral polymorphism of virtual functions and the type polymorphism of templates.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Doesn't that require Log to be explicitly declared as handling a
>specific type of data when instantiated? (something I don't want to do).
Yes. At this point you choose the lesser of two evils. You can't do what you want because the language is defined not to allow it. You can get around it by using a slightly less convenient syntax at the class level. Is there a legitimate reason for not wanting to use a type instantiation of a template class?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Could you attach your code somewhere? I'm curious about your design for this and what it might be used for.
[Translation: I think your design bites, but admit that there could be valid reasons for what you're doing and want to double check before I inform you ;)]
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Be gentle.
Okay. Both your code and your design are pretty fugly. I kept having traumatic flashbacks to early Java while reading your code. But, I can now see why you're doing what you're doing with the way you backed yourself into a corner like that. ;) What were you planning on using this program for?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Could you provide more specific constructive criticism/improvements other than 'fugly'?
I was hoping to avoid that, but here are my main complaints without delving too deeply into the code.
#ifndef __BASE_CLASS__
#define __BASE_CLASS__
Two leading underscores are always reserved by the implementation. As such, you shouldn't be surprised if your code mysteriously fails to compile.
You use too many Java conventions for the code to be comfortably read as C++ like the naming conventions and the Java-style interface usage (but it gets better as you go down the list of files), and while it may be old, several parts could be handled with existing libraries, such as Boost, so there's a huge amount of reinventing the wheel.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Could you give me an example of what you mean regarding the java style interface?
I can give you two: Printable and Identifiable.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401