私は宿題に助けが必要です。私は駐車場のコードを書く必要があります。それを書くために、ヒープ上に作成されたクラス "Parkbox
"のインスタンスの入力をコピーし、別のクラス "Parkinggarage"を#define EMPTY "--------".
とコピーする必要があります。これは私のコードです: Parkbox定義:クラスのインスタンスとC++のchar *変数を比較するにはどうすればよいですか?
class Parkbox{
char *license_plate; // car's license plate
public:
Parkbox(); //Default CTOR
Parkbox(char *); // CTOR
~Parkbox(); // DTOR
void show();
};
and ParkingGarage:
class ParkingGarage{
Parkbox ***p2parkboxes;
と私のCTORまたはParkingGarageヒープ上Parkboxインスタンスを作成するために:
「いいえ演算子」ということ、それは私にエラーを与える方法を、これまでの点で「p2parkboxes[f][r][c]==EMPTY
」
ParkingGarage::ParkingGarage(const int rw,const int clm, const int plns){
p2parkboxes = new Parkbox **[plns];//points to the floors and make the arraq of p2p same size as number as floors
for(int p=0;p<plns;p++){
p2parkboxes[p]= new Parkbox *[plns];//for each Plane creats an array of pointer that is same with the num of rows
for(int r=0;r<rw;r++)
p2parkboxes[p][r]= new Parkbox [clm];
}
}
void ParkingGarage::find_next_free_parking_position()
{
for(int f=0;f<dimensions_of_parkhouse[0];f++){
for(int r=0;r<dimensions_of_parkhouse[1];r++){
for (int c=0;c<dimensions_of_parkhouse[2];c++){
//p2parkboxes[f][r][c] is the instance of the class Pakbox
if(p2parkboxes[f][r][c]==EMPTY)
{
next_free_parking_position[0]=p;
next_free_parking_position[1]=r;
next_free_parking_position[2]=c;
}
}
}
}
}
== "これらのオペランドと一致します"、。 次に、クラスインスタンスをEMPTYなどの別の変数と直接比較するにはどうすればよいですか?
私はあなたのために明確であるかどうかわかりません。 しかし、私がこの問題を解決しなければ、自分のコードを完成させることができないので、助けてください。
'p2parkboxes [f] [r] [c]'の種類の定義を投稿できますか? – hmjd
はいこれは次のように宣言しています:class ParkingGarage { Parkbox *** p2parkboxes;私は駐車場にオブジェクトを作成しました:ParkingGarage :: ParkingGarage(const int rw、const int clm、const int plns){ \t p2parkboxes = new Parkbox ** [plns]; //フロアをポイントし、 p2parkboxes [p] = new Parkbox * [plns]; //各プレーンに対して、ポインタの配列を作成する(floatと同じサイズのp2pのarraq) \t(int p = 0; p p; p ++){ \t \tそれはの行 \t \tのNUMと同じである(INT R = 0; R
mrmrk
「パークボックス」? – hmjd