Hello everyone,
I'm currently in college for Game programming and I'm coming in having known nothing about programming at all. I'm currently learning Object Orientated C++ Programming. I have been at this one problem for two weeks and I'm completely stumped. I currently have three files the main cpp file, the cpp file with all the information, and then the header file. I'm completely stuck on how to properly call the functions into main here are the following codes. This is just the first of many problems I am working on. All help is highly Appreciated as I'm trying to do this as I've gotten little help from my professor. Whom I believe thinks I should figure this out on my own. But with time restraints, it is exceedingly difficult and I fully intend on graduating and getting into the industry. Again thank you ahead of time for any help in helping me fix this and any future questions.
header:
#define Asteroids_h
class Asteroid
{
private:
int astSpeed;
int astSize;
Asteroid () {}
public:
void displayStats(int AsteroidNumber);
void setSize( int astSize);
void setSpeed(int astSpeed);
int setSpeed()
{
return astSpeed;
}
int setSize()
{
return astSpeed;
}
};
core file:
#include <iostream>
using namespace std;
class Asteroid
{
int astSize;
int astSpeed;
int AsteroidNumber;
public:
Asteroid ( int Size, int Speed, int AsteroidNumber )
{
setSpeed( Size);
setSize (Speed);
}
int getSize()
{
return astSize;
}
int getSpeed()
{
return astSpeed;
}
void displayStats(int AsteroidNumber)
{
cout<< "Asteroids " << endl;
cout<< " Asteroid number " << AsteroidNumber << endl;
cout<< " Size " << astSize << endl;
cout<< " Speed " << astSpeed << endl;
}
void setSize(int Size)
{
astSize = Size;
}
void setSpeed(int Speed)
{
astSpeed = Speed;
}
};
and the main:
#include <iostream>
using namespace std;
#include "Asteroids.h"
int main()
{
Asteroid firstAsteroid();
Asteroid secondAsteroid();
firstAsteroid.setSpeed(20);
secondAsteroid.setSpeed(3);
firstAsteroid.displayStats(1);
secondAsteroid.displayStats(2);
char wait;
cin>> wait;
return 0;
}
the current error(s) I have thus far is the following:
asteroidproject\asteroidmain.cpp(9) : error C2664: 'Asteroid::Asteroid(const Asteroid &)' : cannot convert parameter 1 from 'int' to 'const Asteroid &'
1> Reason: cannot convert from 'int' to 'const Asteroid'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>e:\cit43\asteroidproject\asteroidmain.cpp(10) : error C2664: 'Asteroid::Asteroid(const Asteroid &)' : cannot convert parameter 1 from 'int' to 'const Asteroid &'
1> Reason: cannot convert from 'int' to 'const Asteroid'
1> No constructor could take the source type, or constructor overload resolution was ambiguous