Bonjour à tous,

je suis en train de travailler sur mon projet, et je n'ai pour l'instant fait aucune classe... J'ai donc décidé d'en faire une, mais n'étant pas chez moi, je n'ai pas les infos nécessaires...

Voici ma classe, dans un fichier .h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
      #ifndef prendre_photo_h
#define prendre_photo_h

#include "creer_ville.h"
extern pt_ville VILLES;

class photo{
bool entrepot;
bool centrale;
bool cyber;
public:
//photo(entrepot=false, centrale=false,cyber=false);

void photo::prendre(string nom_vil) {
	while(VILLES) {
		if(VILLES->nom_ville == nom_vil) {
			if(VILLES->entrepot == true) this->entrepot = true; 
			else this->entrepot = false;

			if(VILLES->centrale == true) this->centrale = true; 
			else this->centrale = false;
			
			if(VILLES->cyber == true) this->cyber = true; 
			else this->cyber = false;
		}
	VILLES = VILLES->lien;
	}
}

void photo::afficher_photo(string nom_vil) {
	cout << "ici"<< endl;
	this->prendre(nom_vil); //Si on ne l'a fait pas avant, on va chercher les infos maintenant.
	cout << "La ville " << nom_vil ;
	if(entrepot) cout << " comporte un entrepot,"; 
	else cout << " ne comporte pas d'entrepot,";

	if(centrale) cout << " comporte une centrale,"; 
	else cout << " pas de centrale,";

	if(cyber) cout << " et comporte un centre cybern
Dans un fichier .cpp (ou j'ai inclus le .h), je fais ca:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
photo::afficher_photo(nom_vil);
lors de la compil, j'ai cette erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
g++ -Wall   -c -o lancement_partie.o lancement_partie.cpp
lancement_partie.cpp: Dans function « void lancement_partie() »:
lancement_partie.cpp:40: error: cannot call member function `void
   photo::afficher_photo(const std::string&)' without object
make: *** [lancement_partie.o] Erreur 1
Comment corriger ce pb??

Merci !

Philippe