pinda kaas
Gebruiker
- Lid geworden
- 23 okt 2010
- Berichten
- 19
hoi,
ik heb nu:
[CPP]class GameObj {
protected:
int xpos, ypos; // of gewoon Positie positie
public:
GameObj(const int x, const int y) : xpos(x), ypos(y) {}
virtual ~GameObj() {}
void SetX(const int x) { xpos = x; }
void SetY(const int y) { ypos = y; }
int GetX() const { return xpos; }
int GetY() const { return ypos; }
virtual void Print() const = 0;
// ...
};
class Monster : public GameObj {
public:
Monster(const int x, const int y) : GameObj(x, y) {}
virtual void Print() const {
std::cout << "Monster@" << xpos << "," << ypos << '\n';
}
};
class Speler : public GameObj {
public:
Speler(const int x, const int y) : GameObj(x, y) {}
virtual void Print() const {
std::cout << "Speler@" << xpos << "," << ypos << '\n';
}
};
// Speler s(10,20);
// Monster m(40,50);
// s.Print();
// m.Print();[/CPP]
maar me compiler geeft errors bij cout en zo weet iemand een oplossing
ik heb nu:
[CPP]class GameObj {
protected:
int xpos, ypos; // of gewoon Positie positie
public:
GameObj(const int x, const int y) : xpos(x), ypos(y) {}
virtual ~GameObj() {}
void SetX(const int x) { xpos = x; }
void SetY(const int y) { ypos = y; }
int GetX() const { return xpos; }
int GetY() const { return ypos; }
virtual void Print() const = 0;
// ...
};
class Monster : public GameObj {
public:
Monster(const int x, const int y) : GameObj(x, y) {}
virtual void Print() const {
std::cout << "Monster@" << xpos << "," << ypos << '\n';
}
};
class Speler : public GameObj {
public:
Speler(const int x, const int y) : GameObj(x, y) {}
virtual void Print() const {
std::cout << "Speler@" << xpos << "," << ypos << '\n';
}
};
// Speler s(10,20);
// Monster m(40,50);
// s.Print();
// m.Print();[/CPP]
maar me compiler geeft errors bij cout en zo weet iemand een oplossing