简体   繁体   中英

Apostrophe in word in c++ translator progam

I'm writing a program for a translator. Now, i'm a writing a class for words and it is as follows, i'm having trouble writing the method to return all the words with an apostrophe in a sentence. What should i write after bool Words::isApostophePresent(){

if(.....)

 Words::Words() {}

string Words::getWord(){
      return word;
}

void Words::setWord(string w){
     word=w;
}

int Words::getNumCharacters(){
   return word.length();
}

vector<char> Words::getCharacters(){
      int numChars=word.length();
      for (int i=0;i<numChars;i++){
           characters.push_back(word[i]);
      }
      return characters;
}

bool Words::isFirstCharacterUppercase(){

   if(isupper(word[0])){
      firstCharacterUppercase=1;
   }
   else {
      firstCharacterUppercase=0;
   }
   return firstCharacterUppercase;
}

bool Words::isApostophePresent(){

   if()





}
Words::~Words(){}
#include <string>
#include <iostream>

const std::string STR1 = "Hello'World";
const std::string STR2 = "Hello World";

bool hasApostrophe(const std::string& s){ 
  return s.find("'", 0, 1) != std::string::npos; 
}

int main(int, char**){

    std::cout << STR1 << " has apostrophe = " << hasApostrophe(STR1) << '\n';
    std::cout << STR2 << " has apostrophe = " << hasApostrophe(STR2) << '\n';
    return 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM