私は何人かの友人とゲーム プロジェクトを開始しました。私たちのクラスが出力を表示しない理由を突き止めようとしています。SDL 2.0 が含まれています (重要な場合に備えて、ご承知おきください)。
問題は、継承するクラスがあることです...
class Tile {
private:
int textureId;
public:
Tile();
Tile(int texId);
~Tile();
void Print_Data();
}
class Tile_Gun : public Tile {
private:
int damage;
public:
Tile_Gun();
Tile_Gun(int texId, int dmg);
~Tile_Gun();
void Print_Data();
}
それが基本設定です。そして、両方に対して Print_Data() を実行したいと思います。main() でオブジェクトを作成し、ブレークポイントを設定してデータを制御しました。データはすべて停止し、予想される領域を埋めているようです。しかし、Print_Data() 関数を起動すると、ブレークポイントの couts と cins で停止します (実行されます) が、コンソールには何も追加されません。
何が起こっているのか、さらに情報が必要な場合は、私に教えてください.
クラスの呼び出し方法:
int texId = 0, dmg = 5;
Tile_Gun testgun = Tile_Gun(texId, dmg);
//The 0 passed to the parent constructor with Tile::Tile(texId)
testgun.Print_Data();
編集:
void Tile::Print_Data() {
int dummy;
cout << "My texId is: " << textureId;
cin >> dummy;
}
void Tile_Gun::Print_Data() {
int dummy;
cout << "My damage is: " << damage;
cin >> dummy;
}