谁能帮我这个?我是新来的。任何帮助都是最受欢迎的!
9.3.cpp:在构造函数中'Address::Address(int,std::string.int.std::string,std::String,std::String)': 9.3.cpp:29:51:error:'this ' 不能用作函数
9.3.cpp:在成员函数'int Address::compareTo(const Address&)'中:9.3.cpp:39:26:error:'std::string'没有名为'compareTo'的成员</p>
#include<iostream>
using namespace std;
class Address {
int houseNumber;
string street;
int apartmentNumber;
string city;
string state;
string zipCode; // e.g., "47405-1234"
Address(int houseNumber,
string street,
// no apartmentNumber
string city,
string state,
string zipCode) {
this->houseNumber = houseNumber;
this->street = street;
this->city = city;
this->state = state;
this->zipCode = zipCode;
}
Address(int houseNumber,
string street,
int apartmentNumber,
string city,
string state,
string zipCode) {
this(houseNumber, street, city, state, zipCode);
this->apartmentNumber = apartmentNumber;
}
void print(void) {
std::cout << "Street: " << street << "\nCity: "
<< city << "\nState: " << state << "\nPostal Code: " << zipCode;
}
int compareTo(const Address &a) {
// same conventions as for Strings
return this->zipCode.compareTo(angel);
}
};