Here's how I define my class, can someone point out what is wrong with it.
Blimey O'Reilly, where to start?
Code:
planet::planet()
{
weight = myweight;
plan = myplanet;
}
This is a compile time error. I suspect you are attempting to assign default values to weight & plan (but strangely not to newweight?), but have gone somewhat astray. How can you expect the data members to be initialised correctly in this manner? You are trying to assign values to them using undeclared, uninitialised variables. Are you aware of what an initialiser list is?
Code:
planet::planet(string myplanet)
{
if(myplanet == "Mercury" || myplanet == "mercury") {
return "Mercury";
}
Another compile time error. Constructors cannot return values in the same manner as functions (as your compiler points out).
I could go on to detail other flaws (such as using the comparison operator instead of assigning to newweight in the getweight() function), but I can't be arsed to be honest. I think a better suggestion would be for you to go over the fundamentals of classes until you have a better understanding of what their purpose is and how to implement them. With a bit of perserverance, you'll look back on this effort and laugh / cringe. I know I did at my first efforts.