0
我有這種結構(數組),我想用Class對象填充。什麼是實現這一目標的程序。該教程我用/書也不是詳細的,我不知道該怎麼做。(因爲我的嘗試失敗)如何用類對象填充數組結構?
ARRAY STRUCT struct.h
struct Arr{
int days;
int *M;
};
typedef Arr* Array;
struct.cpp
void constr(Array &o){
//Construct of 1*31 Matrix
o=new Arr;
o->days = days;
o->M = new int[o->days];
CLASS
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是不允許的,而且它必須是dyanmical
謝謝你,現在我需要習慣模板,我對他們什麼都沒有......真的很有幫助,要研究一下模板:D – 2012-04-11 20:58:10