You really should read a tutorial on classes to get an idea of cunstructors.Quote:
If you wouldn't mind I'd like to see an example.
Code:#include <iostream>
using namespace std;
class SpaceShip{
public:
int XCoord;
int YCoord;
SpaceShip(int x, int y);
};
SpaceShip::SpaceShip(int x, int y){
XCoord = x;
YCoord = y;
}
int main(int argc, char* argv[])
{
SpaceShip ThisSpaceShip(20, 30);
cout<<"X Coordinate: "<<ThisSpaceShip.XCoord<<endl<<"Y Coordinate: "<<ThisSpaceShip.YCoord<<endl;
return 0;
}