配列に関する私のコンストラクタに問題があります!私のヘッダファイルでコンストラクタの配列
は私が得たこの(簡体字):
class Student
{
private:
int am;
char name[] ;
int grades[8];
}
そして、私のcppファイル内
この:#include<iostream>
#include<cstdlib>
#include "Student.h"
using namespace std;
Student::Student()
{
}
Student::Student(int am , char name,int grades)
{
this->am=am;
this->name=name;
this->grades=grades;
}
そして、私はこのエラー
[エラー]を取得しています'char *'を 'char [0]'に割り当てる際の互換性のない型
P.S:すでにこのサイトの回答を検索しましたが、私はC++の新機能であり、それを把握できませんでした。
文字列を扱う場合は、実際には 'std :: string'を使用してください。 – NathanOliver
パラメータは 'char name'と宣言していることに注意してください。これはただの文字です。 –
'char'は1文字です。あなたの生徒は本当に名前に一人のキャラクターしか持っていませんか? – Barmar