First a few functions are needed to establish the ground work, specifically copy contructors and the like.
While 'friend' classes and functions could have been used, adding a CGame object or pointer directly to the CMoveGenerator allows for the contruction of building hypothetical moves, e.g. 'What Computer moves are availible if the User moved this way?' (And yeah, I do hear the eye-balls rolling at this point.)
So, for the COwner and CGame class the copy constructor looks like;
|The Copy Constructor|
|CXxxxx::CXxxxx(const CXxxxx& obj)|
: Copy initialization list
|For each element in array, copy obj.array[element]|
The '=' operator function works as follows;
|The Equal Operator|
|const CXxxxx& CXxxxx::operator =(const CXxxxx &obj)|
|If this is NOT equal the address of obj (&obj)then|
Copy obj's data members.
For each element in array, copy obj.array[element]
In anycase, return the object reffered to by this. (*this)
And finally, a kluge to copy from pointers to objects for the CGame class. I went through a bit of hoop-jumping and pointer manipulation and massaging before settling on this to extract pointer data members to copy to temporary objects. (But then I do not know the complete ins-and-outs of C++.) Much like the operator=() function the only difference is that there is no need to return the object to which this reffers;
|void setGame(CGame* aGame);|
void setGame(const CGame* aGame); // overloaded to copy-from this
|If this is NOT equal the address of aGame (&aGame)then|
Copy aGame's data members.
For each element in array, copy aGame->array[element]
Note: that there is NO data validation. While this can be added, it might be better to do that in a separate step.