http://qs321.pair.com?node_id=110442


in reply to Re: OO vs. global variables...
in thread OO vs. global variables...

I know that this is not a C++ forum; however, it is a programming one and learning one language helps with all others...

This is a completely incorrect use of templates. Templates take only a class (not an instance of a class), thus you would get <int, int> rather than <8,8>. What you want here is a constructor that takes two int's (or scalars) as arguments, and builds the class based on this input.

The solution that has point as a base class and three inherited classes, middle-point, edge-point, and corner-point, is what fits best into an OO design pattern. Because the whole purpose of OOP is to have each class only worry about itself. However, you might consider making a line class to determine captures since captures are really line oriented...

Matt

Replies are listed 'Best First'.
Re: Re: Re: OO vs. global variables...
by Masem (Monsignor) on Sep 06, 2001 at 03:46 UTC
    I know the original specification of C++ only allows class names as template parameters, but recent C++ developes allow a larger body of parameters to templates (see (first reasonable link I could find) here for example) -- this type of specification is commonly used to demonstrate how one can do fibonaci calculations all at compile time, rather than run time. Mind you, all these have to be specified at compile time, so that my method would not work with a board that could be dynamically allocated. But from a naming classification, you're talking about the slight difference between a Point-on-an-X-by-Y board, and a Point that knows it's on an X-by-Y board. Minor here, but could be significant in other cases.

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    It's not what you know, but knowing how to find it if you don't know that's important