These:
Code:
addplanet.c:9: error: invalid operands of types `double' and `<unknown type>' to binary `operator<<'
addplanet.c:10: error: invalid operands of types `double' and `<unknown type>' to binary `operator<<'
addplanet.c:11: error: invalid operands of types `double' and `<unknown type>' to binary `operator<<'
...are in reference to these:
Code:
double name=input_planet("The name of the planet is ")<<endl;
double mass=readDouble("The mass of the planet is ",false)<<endl;
double radius=readDouble("The radius of the planet is ",false)<<endl;
You insert endl in a stream via operator<< to put a newline (and flush the stream) into the output stream. You seem to be treating the input_planet and readDouble functions as if they returned a reference to an output stream which is the only way that statement (or at least the parts in red) would work. If that were the case then you still wouldn't be able to assign the resultant stream object to a variable of type double. So, I would therefore assume they return a value of type double in which case why is the <<endl part even there at all?
These:
Code:
addplanet.c:13: error: initializer expression list treated as compound expression
addplanet.c:14: error: initializer expression list treated as compound expression
...are in reference to the following:
Code:
double density(mass,radius);
double gravity(mass,radius);
You're not initializing them properly, you can only initialize with a single value. Unless these are meant to be function prototypes... in which case they are still wrong.
This:
Code:
addplanet.c:20: error: `surface_area' cannot be used as a function
addplanet.c:21: error: `density' cannot be used as a function
addplanet.c:22: error: `gravity' cannot be used as a function
...is in reference to this:
Code:
double surface_area(radius);
double density(mass,radius);
double gravity(mass,radius);
...
planet_info.push_back(surface_area(radius));
planet_info.push_back(density(mass,radius));
planet_info.push_back(gravity(mass,radius));
In the first statement, the variable surface_area is initialized with the value of the radius variable. The other two variable initializations (density/gravity) have already been mentioned as needing work. In the parts in red, you seem to be trying to use the tokens surface_area/gravity/density as function names passing in values as arguments. Once again, are these variables or function prototypes? If they are variables, then just use the variable name. If they are prototypes, then the prototypes are wrong.