簡體   English   中英

為什么我的編譯器不喜歡此語句?

[英]Why doesn't my compiler like this statement?

如果字符串中的字符不是字母或撇號,則應該返回false。 知道為什么它不起作用嗎? 還有一種更好的書寫方式嗎? 我正在嘗試像C ++純粹主義者一樣編寫代碼。

for (std::string::const_iterator it = S.begin(); it != S.end(); ++it)
    if ((*it < 'a' || *it >'z') && (*it > 'A' || *it < 'Z') && (*it != ''''))
        return false;

我看到兩個錯誤:

  • ''''應為'\\''
  • *it > 'A' || *it < 'Z' *it > 'A' || *it < 'Z'應該是*it < 'A' || *it > 'Z' *it < 'A' || *it > 'Z'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM