Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 13/07/2007, à 09:59

Le Barde

[RÉSOLU] Erreur : «NULL" was not declared in this scope

Salut à vous,
Je suis en train de coder un Branch and Bound, et voici la console :

StageFlowShop/C++$ make
g++ -c -pipe -Wall -W -O2 -D_REENTRANT  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I/usr/include/qt3 -o Application.o Application.cpp
Application.cpp:12: attention : unused parameter «argc"
Application.cpp:12: attention : unused parameter «argv"
g++ -c -pipe -Wall -W -O2 -D_REENTRANT  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I/usr/include/qt3 -o BandB.o Flowshop/BandB/BandB.cpp
Flowshop/BandB/BandB.cpp: In member function «void BandB::Developpe()":
Flowshop/BandB/BandB.cpp:43: erreur: «NULL" was not declared in this scope
Flowshop/BandB/BandB.cpp:70: erreur: invalid conversion from «int" to «char*"
Flowshop/BandB/BandB.cpp:70: erreur:   initializing argument 1 of «static void Console::Afficher(char*)"
Flowshop/BandB/BandB.cpp:72: erreur: invalid conversion from «int" to «char*"
Flowshop/BandB/BandB.cpp:72: erreur:   initializing argument 1 of «static void Console::Afficher(char*)"
Flowshop/BandB/BandB.cpp: At global scope:
Flowshop/BandB/BandB.cpp:75: erreur: prototype for «Noeud BandB::NouveauNoeudCourant()" does not match any in class «BandB"
Flowshop/BandB/BandB.h:29: erreur: candidate is: Noeud* BandB::NouveauNoeudCourant()
Flowshop/BandB/BandB.cpp:75: erreur: «Noeud BandB::NouveauNoeudCourant()" cannot be overloaded
Flowshop/BandB/BandB.h:29: erreur: with «Noeud* BandB::NouveauNoeudCourant()"
Flowshop/BandB/BandB.cpp: In member function «Noeud BandB::NouveauNoeudCourant()":
Flowshop/BandB/BandB.cpp:78: erreur: request for member «Length" in «((BandB*)this)->BandB::listeNoeuds", which is of non-class type «ListeNoeuds*"
Flowshop/BandB/BandB.cpp:81: erreur: request for member «Premier" in «((BandB*)this)->BandB::listeNoeuds", which is of non-class type «ListeNoeuds*"
Flowshop/BandB/BandB.cpp:82: erreur: «null" was not declared in this scope
Flowshop/BandB/BandB.cpp:83: erreur: request for member «Premier" in «((BandB*)this)->BandB::listeNoeuds", which is of non-class type «ListeNoeuds*"
Flowshop/BandB/BandB.cpp:85: erreur: «null" was not declared in this scope
make: *** [BandB.o] Erreur 1
StageFlowShop/C++$

Je m'intéresse au '«NULL" was not declared in this scope'. Voici l'en-tête BandB.h :

#ifndef BandB_H
#define BandB_H

#include "Noeud.h"
#include "ListeNoeuds.h"
#include "../Ordo.h"


class BandB

{

	private:
	static int nbJob;

	static int nbMach;

	static double** spij;

	static Ordo* probleme;

	ListeNoeuds* listeNoeuds;

	Noeud* racine;
	Noeud* noeudFils;

	
	public:
	Noeud* noeudOpt;

	int nbDev, nbNoeud;

	double zopt;



	public:
	
	BandB(Ordo* ordo);

	void Developpe();
	Noeud* NouveauNoeudCourant();

};


#endif

Et la méthode qui pose problème dans le source BandB.cpp :

#include "BandB.h"

// En attendant mieux :
#include "../../Entrees-Sorties/Console.h"

//#include "../Ordo.h"



void BandB::Developpe()

		{

			Noeud* noeudCourant = racine;



			while (noeudCourant != NULL)
   // Là, le compilateur râle ; il ne connaît pas NULL ??
			{
				int i;

				// Developpement du noeud courant

				nbDev++;

				for (i=0; i<nbJob - noeudCourant->niveau; i++)

				{

					noeudFils = new Noeud(noeudCourant, i);

					nbNoeud++;

					noeudFils->Evaluer();

					if (noeudFils->borneInf < zopt)

					{

						if (noeudFils->niveau<nbJob)

							listeNoeuds->PlacerEnTete(noeudFils);

						else

						{

							noeudOpt = noeudFils;

							zopt = noeudOpt->borneInf;

						}

					}

				}



				// Nouveau noeud à developper

				noeudCourant = NouveauNoeudCourant();



			}

			Console::Afficher("Nb noeuds apparus: ");

			Console::Afficher(nbNoeud);

			Console::Afficher("\nNb noeuds developpes:");

			Console::Afficher(nbDev);

		}

Si vous aviez une petite idée de ce qui se passe, étant débutant je suis un peu dépassé...
Merci d'avance !

Dernière modification par Le Barde (Le 13/07/2007, à 10:43)

Hors ligne

#2 Le 13/07/2007, à 10:19

cduray

Re : [RÉSOLU] Erreur : «NULL" was not declared in this scope

Hello

Contrairement à ce qu'on croit, NULL n'est pas déclaré en standard, c'est un define repris dans plusieurs header files (dont stdlib.h).

Solution:
ajouter
#include <stdlib.h>

au code


Ou mieux: ne pas utiliser NULL...

while (noeudCourant != NULL)

peut s'écrire (et c'est d'ailleurs conseillé)

while (noeudCourant)

C

Hors ligne

#3 Le 13/07/2007, à 10:42

Le Barde

Re : [RÉSOLU] Erreur : «NULL" was not declared in this scope

Donc NULL n'était effectivement pas déclaré...
Je ne savais pas, merci beaucoup pour ta réponse, claire, bien présentée, et tout big_smile
Je vais mettre plutôt les conditions comme tu dis.

Hors ligne