Hi,
I am trying to create an array of objects but I keep getting errors.
Help me please.
The class is correct (no errors there).
thanks.Code:#include<iostream> class Dominos { private: float x; float z; float angle; public: Dominos(float y,float z,float angle); float getX(); float getZ(); float getA(); }; Dominos::Dominos(float x,float z,float angle) { this->x = x; this->z = z; this->angle = angle; } float Dominos::getX() { return x; } float Dominos::getZ() { return z; } float Dominos::getA() { return angle; } int main() { Dominos dom = new Dominos[100]; dom[0] = new Dominos(1,2,3); printf("X %f\n",dom[0].getX()); printf("Z %f\n",dom[0].getZ()); printf("A %f\n",dom[0].getA()); return 0; }



LinkBack URL
About LinkBacks


