前提
C++を思い出すために色々想定問題を解いています。(解説がない)
それでVector で 設定したクラス を以下のように
vCustomer[i].setAge(age);
のようにしようとするとエラーになります。
どうすればクラスのメソッドが使えるのかお伺いしてよろしいでしょうか?
以下ソースを貼り付けます。
#include <iostream> #include <string> #include <vector> using namespace std; /* order注文クラス */ class orderCustomer { public: int iTotalPrice; int iCustomerNo; int iAge; void setAge(int age) { iAge = age; } private: }; int main() { //// データ初期設定 ココから int iPeopleNum, iOrderNum;//人数とオーダー数 cout << "ninnzuu to order suu nyuuryoku" << endl; cin >> iPeopleNum >> iOrderNum;//を読み込む //宣言 std::vector<orderCustomer> vCustomer[1000]; cout << "age input" << endl; int age; for (int i = 0; i < iPeopleNum; i++) { cin >> age; vCustomer[i].setAge(age); } }
ご助力頂けますと嬉しく思います。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/08/23 08:57
2022/08/23 12:06
2022/08/23 13:00
2022/08/23 15:35
2022/08/23 22:03
2022/08/23 23:55
2022/08/24 00:05 編集
2022/08/24 01:36
2022/08/24 03:36
2022/08/24 03:47