Hello! google has turned me up at this forum so many times i think it would be stupid to ignore the hints & not get registered! Im having some problems with objects. Here is my code:
#include <iostream>
#include <string>
using namespace std;
class planet{
public:
int moons;
int mass;
}mercury, venus, earth, mars, jupiter, saturn, uranus, neptune;
int main()
{
string input;
cout << "enter a planet:";
getline(cin, input);
cout << input << " has " << input.moons << " moons\n";
cout << input << " has a mass of " << input.mass;
return 0;
}
/*i would like to know the quickest way to acheive this effect - the closest my knowledge allows involves nesting 8 if statements for each planet name */
Ive been pointed a couple of times in the direction of maps, but ive no idea how id have to implement them in this scenario. Any help would be much appreciated! Ive run into this before & its been annoying me for the past 5 hours. i really cant understand maps.