1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <cstdlib>
#include <iostream>
#include <cstdio>
using namespace std;
class Personnage
{
public:
string Nom;
virtual void Display()=0; // Fonction virtuelle pure.
//-----------------------------------------
class Guerrier : public Personnage
{
public:
Guerrier (string Nom_Choisit)
{
Nom = Nom_Choisit;
} // constructeur
virtual void Display() // La fameuse méthode
{
cout <<Nom;
}
}
;
//-----------------------------------------
//...
// Exactement pareil pour les class suivantes
int main(int argc, char *argv[])
{
cout
<<"Quel personnage voulez-vous etre?" <<endl
<<"1- Un guerrier, " <<endl
<<"2- un voleur, " <<endl
<<"3- un elfe, " <<endl
<<"4- Un nain, " <<endl
<<"5- un mage noir. " <<endl;
Choix_De_la_Classe=Read_Choice(6,1);
// verifie que la varible est bien entre 1 et 6.
switch ( Choix_De_la_Classe)
{
// Si =1, creer un guerrier... Guerrier joueur1("Joueur 1");
}
// Et là, j'arrive pas à appeler la méthode Display()
// d'apres mon pc, joueur1 n'est pas déclaré.
system("PAUSE");
return EXIT_SUCCESS;
} |
Partager