Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: what classes all the serious C++ chess programs have?

Author: Daniel Clausen

Date: 14:53:47 08/11/04

Go up one level in this thread


On August 11, 2004 at 14:22:50, Volker Böhm wrote:

>On August 11, 2004 at 03:21:53, Daniel Clausen wrote:
>
>>On August 10, 2004 at 13:22:55, Volker Böhm wrote:
>>
>>[snip]
>>
>>>>>1. A "Const" Class holding only constants that do not need memory (no const
>>>>>fields). Nearly every class is derived from the const class giving it the
>>>>>opportunity to access all relevant constant values.
>>
>>Just noticing this now: you _derive_ from that const class? That sounds like the
>>wrong concept to me in this case. Why not simply include its headerfile and use
>>access the const values this way?
>>
>>Sargon
>
>Why is the concept wrong? Both solutions are nearly identical.

There are always special cases, but the general rule I use when deciding between
composition and inheritance is this. Is A a B? If yes, I consider A being a
subclass of B. Otherwise not.

Example: An apple is a fruit, therefore it makes sense for me if class Apple
derives from class Fruit. (although I still might choose using composition for
other reasons)

Your example more sounds like class XYZ merely _uses_ the Const Class. Class XYZ
is not A Const.

But then, classes which only provide static stuff are special anyway. Your Const
class sounds like it could simply be a namespace.

Sargon



This page took 0 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.