I am fairly new to c++ and I am in my second quarter in college. On my assignment, I have this code here that is not working when I try to run it. It gives me the errors of "cannot convert parameter 1 from 'const char [17]' to 'int'... There is no context in which this conversion is possible" for lines 61,62, and 63. Would anyone be able to tell me how to fix my code to make the program work, as well as tell me why my code was wrong? Thank you.
Here's my code:
#include <string>
#include <iostream>
using namespace std;
class Spacecraft
{
private:
string m_name;
int m_energy;
int m_weight;
int m_capacity;
public:
string getName();
void setName(string newName);
int getEnergy();
void setEnergy(int newEnergy);
int getWeight();
void setWeight(int newWeight);
int getCapacity();
void setCapacity(int newCapacity);
};
string Spacecraft::getName()
{
return m_name;
}
void Spacecraft::setName(string newName)
{
m_name = newName;
}
int Spacecraft::getEnergy()
{
return m_energy;
}
void Spacecraft::setEnergy(int newEnergy)
{
m_energy = newEnergy;
}
int Spacecraft::getWeight()
{
return m_weight;
}
void Spacecraft::setWeight(int newWeight)
{
m_weight = newWeight;
}
int Spacecraft::getCapacity()
{
return m_capacity;
}
void Spacecraft::setCapacity(int newCapacity)
{
m_capacity = newCapacity;
}
void main()
{
Spacecraft values;
values.setName("System Values");
values.setEnergy("18,000 kilowatts");
values.setWeight("25,000 lbs");
values.setCapacity("20,000/20,000... FULL CAPACITY");
cout << values.getName() << endl;
cout << " " << endl;
cout << " " << endl;
cout << values.getEnergy() << endl;
cout << values.getWeight() << endl;
cout << values.getCapacity() << endl;
system("pause");
}
Here's my code:
#include <string>
#include <iostream>
using namespace std;
class Spacecraft
{
private:
string m_name;
int m_energy;
int m_weight;
int m_capacity;
public:
string getName();
void setName(string newName);
int getEnergy();
void setEnergy(int newEnergy);
int getWeight();
void setWeight(int newWeight);
int getCapacity();
void setCapacity(int newCapacity);
};
string Spacecraft::getName()
{
return m_name;
}
void Spacecraft::setName(string newName)
{
m_name = newName;
}
int Spacecraft::getEnergy()
{
return m_energy;
}
void Spacecraft::setEnergy(int newEnergy)
{
m_energy = newEnergy;
}
int Spacecraft::getWeight()
{
return m_weight;
}
void Spacecraft::setWeight(int newWeight)
{
m_weight = newWeight;
}
int Spacecraft::getCapacity()
{
return m_capacity;
}
void Spacecraft::setCapacity(int newCapacity)
{
m_capacity = newCapacity;
}
void main()
{
Spacecraft values;
values.setName("System Values");
values.setEnergy("18,000 kilowatts");
values.setWeight("25,000 lbs");
values.setCapacity("20,000/20,000... FULL CAPACITY");
cout << values.getName() << endl;
cout << " " << endl;
cout << " " << endl;
cout << values.getEnergy() << endl;
cout << values.getWeight() << endl;
cout << values.getCapacity() << endl;
system("pause");
}