도움이 필요하십니까? 아래와 같은 오류를 해결하는 방법은 무엇입니까?오류가 필요합니다.
30:24:error:expected ')' before ',' token
In member function 'int Address::compareTo(const Address&)':
41:26:error:'std::string' has no member named 'compareTo'
#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(a);
}
};
"41 : 26 : 오류 : 'std :: string'에 'compareTo'라는 멤버가 없습니다?" [std :: string reference] (http://en.cppreference.com/w/cpp/string/basic_string)를 참조하십시오. – juanchopanza
가능한 복제본 [C++ 몇 가지 오류가 있습니다] (http://stackoverflow.com/questions/12276247/c-a-few-errors-here) –