2016-11-26 1 views
0

나는 지난 질문을 통해 특정 답변을 찾을 수 없습니다. 광산. 그래서, 나는이 방법으로 오류를 계속 얻는다. 당신의 도움에 정말로 감사 할 것입니다.오류 : '연산자 =='에 일치하지 않음 (피연산자 유형이 '좌석'이고 'std :: string {aka std :: basic_string <char>}')

오류 :

error: no match for 'operator==' (operand types are 'Seat' and 'std::string {aka std::basic_string}')

void SeatsCreateReservation(vector<Seat>& seats) { 
string account_ID; 
unsigned int seatNum = 0; 
Seat seat; 
cout << "Enter username: "; 
cin >> account_ID; 

for (seatNum = 0; seatNum < seats.size(); seatNum++) { 
    if (seats.at(seatNum) == account_ID) { 
    cout << "Seat number too large." << endl; 
    break; 
    } 
    } 
    seat.Reserve(account_ID); 
    seats.at(seatNum) = seat; 
    cout << "Completed." << endl; 
    return; 
} 
+0

부분 오류 메시지가 확실하지 않습니까? 'seats.at (seatNum) == account_ID'는 한편으로는 'Seat'인스턴스와 다른 한편으로는'std :: string' 인스턴스를 비교하려고 시도하지만이 비교를 수행 할 수단을 구현하지 않았습니다. –

답변

1

것 같다 매우 자명 :

no match for ' operator== ' (operand types are ' Seat ' and ' std::string {aka std::basic_string} ')

Seat 유형 및 우측의 좌측을 허용 == 존재 연산자의 어떠한 구현되지 std::string의 손 쪽. 당신은 사과와 오렌지를 비교하려고하기 때문에 당신은 당신이 수행하는 방법을 알려해야합니다 다음 그들을 비교할 컴파일러를 확인하려면 의미가

예는 다음의

bool operator==(const Seat& seat, const std::string&string) { 
    ... 
} 
관련 문제