<分区>
我的代码有问题。实际上它可以工作,但我想清理它以使其更合适。
所以我有一个 Coord 类,它包含一个 float x 和一个 float y。
构造函数是:
void Coord::Coord (float x,float y)
{
this->x = x;
this->y = y;
}
我以这种方式创建我需要的所有点:
Coord pt1(0,1);
Coord pt2(20,0);
...
Coord pt61(12,14); .... `
例如,在我必须制作一些点的数组之后 第五个点将分配到一个数组中,另外 4 个点分配到另一个数组中,另外 2 个点分配到另一个数组中...
Coord pts_weakhealth[3] = {pt1,pt2,pt3};
这个数组,我必须作为类的构造函数的参数 例如:
Sef health(pts_weakhealth,3);
Sef strength(pts_weak,4);`
我将以同样的方式创建一些 Sef,然后将它们组成一个数组
Sef spec[2] = {health,strength};
类 universe 将包含一些 sef :
Universe hlth(spec);
你可以想象,当我有很多点,很多sef,就是很多脏代码...
我该如何改进?使我的代码更好...