プロが教える店舗&オフィスのセキュリティ対策術

C++を学習し始めて2,3日なのですが、1つつまずいている所があります。
独習C++という参考書を読みながら進めているのですが
cardというクラスを作成し、そのクラスの中でset()でメンバを初期化して、show()で示すという課題を行っており

#include <iostream>

class card {
private:
std::string title; // 本のタイトル
std::string author; // 本の著者
int store; // 本の在庫

public:
void set(std::string title, std::string author, int store);
void show();
};

void card::set(std::string title, std::string author, int store){
this.title = title;
this.author = author;
this.store = store;
}

void card::show(){
std::cout << "タイトル:" << "\t" << title << std::endl;
std::cout << "著者名:" << "\t" << author << std::endl;
std::cout << "在庫数:" << "\t" << store << std::endl;
}

int main(){

std::string title = "タイトル01";
std::string author = "著者名01";
int store = 60;

card c;
c.set(title, author, store);
c.show();

return 0;
}

上記のコードを書いてみたのはいいのですが、これだとコンパイル出来ず解決策が分かりません...
どこをどのように修正すれば良いのでしょうか?

質問者からの補足コメント

  • すいません、回答者さんのおかげで気付きましたが、エラーを載せ忘れていました。

    以下がコンパイルエラーの文です。CLionでコードを書いております。
    文が長いので分割して補足します。

    C:\CLionProjects\untitled\main.cpp:15:8: error: request for member 'title' in '(card*)this', which is of pointer type 'card*' (maybe you meant to use '->' ?)
    this.title = title;
    ^~~~~

      補足日時:2019/03/13 16:16
  • C:\CLionProjects\untitled\main.cpp:16:8: error: request for member 'author' in '(card*)this', which is of pointer type 'card*' (maybe you meant to use '->' ?)
    this.author = author;
    ^~~~~~
    C\CLionProjects\untitled\main.cpp:17:8: error: request for member 'store' in '(card*)this', which is of pointer type 'card*' (maybe you meant to use '->' ?)
    this.store = store;
    ^~~~~

      補足日時:2019/03/13 16:17
  • mingw32-make.exe[3]: *** [CMakeFiles\untitled.dir\build.make:62: CMakeFiles/untitled.dir/main.cpp.obj] Error 1
    mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:72: CMakeFiles/untitled.dir/all] Error 2
    mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:84: CMakeFiles/untitled.dir/rule] Error 2
    mingw32-make.exe: *** [Makefile:117: untitled] Error 2

      補足日時:2019/03/13 16:17

A 回答 (2件)

プログラミング経験はC++が初めてですか?



とりあえず、他の言語の経験がある前提で回答しますね

thisはポインタです。
    • good
    • 0

せめて出ているエラーとか


行数を書いてください
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!