Bonsoir
Voilà 1 semaine, j´ai acheté un livre pour débuter la POO. Pour le moment, je m´en sors bien, j´arrive à suivre
Mais depuis 2 jours, je n´arrive pas à compiler le programmme
Fichier Decryptix:
- include < cstdlib>
- include < iostream>
- include " Game.h"
using namespace std;
int main(int argc, char *argv[])
{
Game theGame;
system("PAUSE");
return EXIT_SUCCESS;
}
Fichier Game.h:
class Game
{
public:
Game();
~Game();
void Play();
bool duplicatesAllowed;
int howManyLetters;
int howManyPositions;
int round;
};
Fichier Game.cpp:
- include < iostream.h>
- include " Game.h"
Game::Game():
round(1),
howManyPositions(0),
howManyLetters(0),
duplicatesAllowed(false)
{
enum BoundedValues
{
minPos = 2;
maxPos = 10;
minLetters = 2;
maxLetters = 26;
};
bool valid = false;
while(! valid)
{
while(howManyLetters < minLetters || howManyLetters > maxLetters)
{
cout < < " Nombre de lettres: " ;
cout < < minLetters < < " -" < < maxLetters < < " : " ;
cin > > howManyLetters;
if(howManyLetters < minLetters || howManyLetters > maxLetters)
{
cout < < " Veuillez entrer un nombre compris entre " ;
cout < < minLetters < < " et " < < maxLetters < < endl;
}
}
while(howManyPositions < minPositions || howManyPositions > maxPositions)
{
cout < < " Nombre de position: " ;
cout < < minPositions < < " -" < < maxPositions < < " : " ;
cin > > howManyPositions;
if(howManyPositions < minPositions || howManyPositions > maxPositions)
{
cout < < " Veuillez entrer un nombre compris entre " ;
cout < < minPositions < < " et " < < maxPositions < < endl;
}
}
while( choice ! = ´o´ && choice ! = ´n´)
{
cout < < " Permettre les doubles ( o/n) : " ;
cin > > choice;
}
duplicatesAllowed = choice == ´o´ ? true : false;
if(! duplicatesAllowed && howManyPositions > howManyLetters)
{
cout < < " Impossible de mettre " < < howManyLetters;
cout < < " lettres dans " < < howManyPositions;
cout < < " positions sans doublons." < < endl;
cout < < " Reessayer\n" < < endl;
howManyLetters = 0;
howManyPositions = 0;
}
else
valid = true;
}
}
Game::~Game()
{
}
void Game::Play()
{
}
Erreurs retournées:
In file included from
C:/DEV-CPP/include/c++/3.4.2/backward/iostream.h:3
1,
from Game.cpp:1:
C:/DEV-CPP/include/c++/3.4.2/backward/backward_war
ning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the < X> header for the < X.h> header for C++ includes, or < iostream> instead of the deprecated header < iostream.h>. To disable this warning use -Wno-deprecated.
Game.cpp:2:16: Game: No such file or directory
Game.cpp:4: error: `Game´ has not been declared
Game.cpp:4: error: ISO C++ forbids declaration of `Game´ with no type
Game.cpp: In function `int Game()´:
Game.cpp:4: error: only constructors take base initializers
Game.cpp:12: error: expected `}´ before ´;´ token
Game.cpp:13: error: `maxPos´ undeclared ( first use this function)
Game.cpp:13: error: ( Each undeclared identifier is reported only once for each function it appears in.)
Game.cpp:14: error: `minLetters´ undeclared ( first use this function)
Game.cpp:15: error: `maxLetters´ undeclared ( first use this function)
Game.cpp: At global scope:
Game.cpp:20: error: expected unqualified-id before " while"
Game.cpp:20: error: expected `,´ or `;´ before " while"
Game.cpp:68: error: expected declaration before ´}´ token
g++.exe Decryptix.o Game.o -o " Projet_Decryptix.exe" -L"C:/DEV-CPP/lib"
G__~1.EXE: Game.o: No such file or directory
Je pense que c´est au niveau de l´include de Game.h.
J´ai tout essayé, mais rien à faire...
Le code est identique au livre, j´ai vérifié et encore vérifié.
Si quelqu´un peut m´aider
Merci
PS
Désolé pour la longeur du post.