#include #include using namespace std; // ノートクラス. class Notebook { private: string note; // ノートの本文. public: string Read(void) const; // ノートを読む. void Write(string); // ノートに書く. }; // ノートを読む. string Notebook::Read() const { return note; // noteの内容を返す. } // ノートに書く. void Notebook::Write(string str) { note = str; // noteに代入する. } int main() { Notebook notebook; // ノートクラスのインスタンス. notebook.Write("This is a notebook."); // ノートに書き込んで. cout << notebook.Read() << endl; // それを読む. notebook.Write("This notebook is good."); cout << notebook.Read() << endl; return 0; }