掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
実行エラー (ID:56052)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
一応今malloc関数を使用して初期化しました。 ですが今度はこんなエラーがでました。 no operator defined which takes a right-hand operand of type 'int *' (or there is no acceptable conversion) 一応必要な関数は全て定義してるはずなんですがなぜでしょうか? もう一度ソースを載せますね^−^; 度々すいません。 #include <iostream.h> #include <string> #include <stdlib.h> #include <malloc.h> #include <memory.h> using namespace std; //Demographic class class Demographic{ int *age; char *name; public: Demographic( char *s, int *a ){name = (char *)malloc(sizeof(char)*30); age = (int *)malloc(sizeof(int)*30);strcpy(name,s); age = a;} void call(){cout << "\t Student Name is " << name << endl; cout << "\t Student Age is " << age << endl;} }; //Generation Class class Generation{ public: Generation(){}; void Make(); }; void Generation::Make(){ char *StName; int *StAge; StName = (char *)malloc(sizeof(char)*30); StAge = (int *)malloc(sizeof(int)*30); cout << "\t Please enter your students' name and age." << endl; cout << "\t Student Name :: "; cin >> StName; cout << "\n\t Student Age ::"; cin >> StAge; Demographic St( StName,StAge ); system("cls"); St.call(); } int main(){ Generation A; A.Make(); return 0; }
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.