I need a little bit of help here. I'm new to C++ Classes.
There are some errors which I do not know how to troubleshoot.
The error of "Declaration terminated incorrectly".
Multiple errors of "Type name expected". Why is that?
Multiple errors of "Declaration missing ;". Why is that?
int compareTo(Address a) {
// same conventions as for Strings
returnthis.zipCode.compareTo(a.zipCode);
}
1) If it isn't a built-in datatype then be sure to pass it in by reference.
2) What is this function supposed to do?
This function takes an Address object as an argument but you are passing in a string. Why is that? And this is a pointer, so the code should look like this.
1 2 3 4
int compareTo(const Address &a) {
// same conventions as for Strings
returnthis->zipCode.compareTo(a);
}
EDIT: The function is supposed to return an integer. >_> Why is that?
1 2 3 4
void print(void) {
std::cout << "Street: " << street << "\nCity: "
<< city << "\nState: " << state << "\nPostal Code: " << zipCode;
}
This is C++, not Java. How do you confuse the two? The code above is a valid print function for your class.