メインのみを実行しています。出力は「単語を入力してください」ですが、オブジェクト/クラスは完全に無視されます
私は初心者です。これが不適切に簡単な質問である場合は申し訳ありません。これは、リリース モードとデバッグ モードの両方で発生します。
#include <iostream>
using namespace std;
class WordGame
{
public:
void setWord( string word )
{
theWord = word;
}
string getWord()
{
return theWord;
}
void displayWord()
{
cout << "Your word is " << getWord() << endl;
}
private:
string theWord;
};
int main()
{
cout << "Enter a word" << endl;
string aWord;
WordGame theGame;
cin >> aWord;
theGame.setWord(aWord);
theGame.displayWord();
}