私はクラスオブジェクトで埋めたいこの構造(配列)を持っています。それを達成するための手順は何ですか。私が使用したチュートリアル/本はそれほど詳細ではなく、その方法がわかりません.(試行が失敗したため)
配列構造 struct.h
struct Arr{
int days;
int *M;
};
typedef Arr* Array;
構造体.cpp
void constr(Array &o){
//Construct of 1*31 Matrix
o=new Arr;
o->days = days;
o->M = new int[o->days];
クラス
expe.h
class Expe {
private:
int *obj;
public:
Expe();
~Expe();
void setObj(int ,int ,int ,int ,int ,int);
void printObj();
int getObj();
enter code here
expe.cpp
Expe::Expe() {
this->obj=new int[6];
}
Expe::~Expe() {
delete this->obj;
}
ps: 独自の構造体 vector.h を使用する必要があります。h は許可されておらず、動的でなければなりません。