J
JoeC
I am trying to design some complex objects that have quite a bit of
data. I understand most syntax but I am trying to learn how to make
better design choices. The first question is to OK or good design to
have large objects with several has-a relationship with other objects.
Second, I want my unit to have a coord struct.
struct coord{
int x;
int y;
coord(const int xx, const int yy){x = xx; y = yy;}
bool operator ==(const coord c){return c.x == x && c.y == y;}
};
+++++++++++++++
class unit{
protected:
coord loc;
It give me an error. I want to have a place function that will
actually fill in the coords.
Which is better?
Have a default constuctor that sets the x and y to 0 or to:
loc.x = x; loc.y = y;
coord * loc; and in my place function:
loc = new coord(x, y);
I know there are many ways to do things and I they might not be
appearent when I am in an earlier stage of devlopment but these choices
have affects that make it harder to expand and maintain my code.
I have a working copy of the game:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=10766&lngWId=3
data. I understand most syntax but I am trying to learn how to make
better design choices. The first question is to OK or good design to
have large objects with several has-a relationship with other objects.
Second, I want my unit to have a coord struct.
struct coord{
int x;
int y;
coord(const int xx, const int yy){x = xx; y = yy;}
bool operator ==(const coord c){return c.x == x && c.y == y;}
};
+++++++++++++++
class unit{
protected:
coord loc;
It give me an error. I want to have a place function that will
actually fill in the coords.
Which is better?
Have a default constuctor that sets the x and y to 0 or to:
loc.x = x; loc.y = y;
coord * loc; and in my place function:
loc = new coord(x, y);
I know there are many ways to do things and I they might not be
appearent when I am in an earlier stage of devlopment but these choices
have affects that make it harder to expand and maintain my code.
I have a working copy of the game:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=10766&lngWId=3