Author: Mathieu Pagé
Date: 06:26:37 01/06/06
Go up one level in this thread
On January 05, 2006 at 16:35:09, José Carlos wrote: >On January 05, 2006 at 14:47:09, Mathieu Pagé wrote: > >>On January 05, 2006 at 14:13:07, Dann Corbit wrote: >> >>>On January 05, 2006 at 13:04:29, Mathieu Pagé wrote: >>> >>>>Hi, I want to push OO to it's limit in order to get cleaner code. Here is what I >>>>want to do : >>>> >>>> >>>>class CSquare >>>> { >>>> private: >>>> unsigned int m_uiSquareIndex; >>>> public : >>>> // the next 3 functions allow CSquare to be used as an unsigned int in >>>> // arithmetic operations. >>>> inline CSquare(unsigned int); >>>> inline CSquare operator=(unsigned int); >>>> inline operator unsigned int(); >>>> >>>> // The next 2 functions are why i'd like to use OOP to make the >>>>manipulation >>>> // of squares clearer. >>>> unsigned int GetColumn() >>>> { >>>> return m_uiSquareIndex % 8; >>>> }; >>>> >>>> unsigned int GetRow() >>>> { >>>> return m_uiSquareIndex / 8; >>>> }; >>>> }; >>>> >>>> >>>>This way I can use CSquare like this : >>>> >>>> >>>>CSquare csq(A1) >>>>csq += 8; // One row higher. csq is now equat to A2. > > > Apart from what Dann said, I'd like to suggest something like: > > csq.GetOneRowHigher(); > > And then implement the += 8 operation inside the function. > > José C. Hi José, You are the second to make that suggestion. Adopted :) Thanks for your answer. Mathieu Pagé
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.