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;
}
上記のコードを書いてみたのはいいのですが、これだとコンパイル出来ず解決策が分かりません...
どこをどのように修正すれば良いのでしょうか?
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- C言語・C++・C# C++初心者です stirng 2 2022/09/20 20:43
- C言語・C++・C# C++プログラミングコードにポリモーフィズムを取り入れ方を教えてください。 2 2023/06/09 11:17
- C言語・C++・C# このプログラミング誰か教えてください 9 2022/04/22 18:50
- C言語・C++・C# このプログラミング誰か教えてくれませんか 3 2022/05/13 17:27
- C言語・C++・C# このプログラミング誰か教えてくれませんか 2 2022/05/14 09:45
- C言語・C++・C# このプログラミング誰か教えてください。 2 2022/04/22 18:48
- C言語・C++・C# C++のcinの動作 5 2023/02/26 00:13
- Java java 入力 3 4 3 出力 ABC DEFG HIJ このようなプログラムの書き方を教えてくだ 2 2022/07/15 14:18
- C言語・C++・C# メインプログラムに#include <algorithm>を書いて、 そのメインプログラムが // 3 2023/05/02 11:24
- C言語・C++・C# プログラミング c言語 4 2023/03/07 01:05
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
構文エラーが出ているのですが...
-
#defineの使い方について
-
openCVで動画が読み込めないエ...
-
なぜ、C++の標準ヘッダをインク...
-
指定した文字を削除したい
-
#include "fstream.h"
-
#define中の#のエスケープ
-
Linux Ubuntu19.10でQt5.14.1の...
-
STLでポインタのリストをsort()...
-
JPEGやPNGが読めるLoadImage関数
-
テイラー展開とその精度について
-
構造体配列のvectorへの変換と...
-
ファイル読み込みとmap処理
-
【C++】ヘッダ内でstringを格納...
-
コーディング
-
C言語からgnuplot呼び出し
-
構造体に決められた文字列を入...
-
mapの初期化
-
snprintfが使用できない。
-
Cでのパケットキャプチャについて
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
構文エラーが出ているのですが...
-
VC++で文字列から任意の文字を...
-
enumの値から定義名を文字列化...
-
switch文のエラーについて
-
空ENTERの判別
-
なぜ、C++の標準ヘッダをインク...
-
【C++】ヘッダ内でstringを格納...
-
C++での <iostream.h>と<iostre...
-
#include "fstream.h"
-
#define中の#のエスケープ
-
JPEGやPNGが読めるLoadImage関数
-
リモートデスクトップの接続元I...
-
CStringとString
-
string型のフォーマット書式指...
-
std::map の const 修飾について
-
VHDLのsignedとunsignedの違いは?
-
このプログラミング誰か教えて...
-
構造体配列のvectorへの変換と...
-
指定した文字を削除したい
-
構造体に決められた文字列を入...
おすすめ情報
すいません、回答者さんのおかげで気付きましたが、エラーを載せ忘れていました。
以下がコンパイルエラーの文です。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;
^~~~~
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;
^~~~~
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