2013-08-16 4 views
-2

Я новый программист Whos запустить в compilling ошибку, что я не понимаю и надеюсь Сомон может помочь мне понять, почему ошибкаC++ синтаксис ошибка компиляции

31 F:\C++ Programming\Chapter 13\Exercises\Exercise 32.cpp no match for 'operator||' in '(((std::operator== [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&letter))), ((const char*)"a")) || std::operator== [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&letter))), ((const char*)"e"))) || std::operator== [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&letter))), ((const char*)"i"))) || std::operator== [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&letter))), ((const char*)"o"))) || letter' 

код

#include <iostream> 
#include <string> 
using namespace std; 


main() 
{ 
string word = ""; 
string letter = " "; 
int count = 7; 
string temp = ""; 
int x = 0; 
//end declair 

cout << "Please enter a word: "; 
getline(cin, word); 
count = word.length(); 
letter = word.substr(0, 1); 

if(letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u") 
{ 
    word.insert(count, "-way"); 
    cout <<"word starting with vowel is "<<word<<endl; 
} 
    while(letter != "a" && letter != "e" && letter != "i" && letter != "o" && 
    letter != "u"||   letter == "y") 
{ 
    x = 0; 
    while(x < count) 
    { 
     letter = word.substr(0, 1); 
     word.insert(count, "-"); 
     if(letter == "a" || letter == "e" || letter == "i" || letter == "o" ||//error is here 
    letter || "u"|| letter == "y") //error iss here 
     { 
      temp = letter; 
      cout <<letter <<" ------------------------"<<endl; 
      word.erase(x, 1); 
      cout <<word <<" ------------------------"<<endl; 
      word.insert(x, letter); 
      cout <<word <<" ------------------------"<<endl; 

      letter = word.substr(0, 1); 

     } 
     x += 1; 
    } 
     cout <<"word starting with letter is "<<word<<endl;    
} 
system("pause"); 
} 
+3

Вы бы гораздо лучше с 'isVowel' функции. Было бы полезно указать, где эти ошибки также происходят. – chris

ответ

-1

использование функция-член функция сравнение

letter.compare("a") 
1

letter || "u" должно быть: letter == "u"

1
|| letter || "u")// 

// пробует

|| letter == "u")// 
+0

исправлено сейчас спасибо dru, я не знал, что вы можете это сделать –

Смежные вопросы