Undefined Error

This is a discussion on Undefined Error within the C++ Programming forums, part of the General Programming Boards category; I seem to have a problem with my code, anytime I try to initialize the constructor PlaneList I recieve a ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    36

    Undefined Error

    I seem to have a problem with my code, anytime I try to initialize the constructor PlaneList I recieve a not defined error. It shouldn't be because PlaneList.h is included. Assignment is due in hours and spent several just with this compile bug.

    What I find weird is my EventList(which is similar toPlaneList, and extends OrderedList) works perfectly fine, with a call to the constructor almost identical.


    Any foolish things I'm doing wrong?


    Undefined first referenced
    symbol in file
    PlaneList::PlaneList(void) /var/tmp/ccjIE1oK.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status


    Code:
    // CLASS: Simulation Header
    //
    // REMARKS: constrols all simulation related things - many static variables
    //
    // INPUT: none
    //
    // OUTPUT: none
    //
    //-----------------------------------------
    
    #ifndef SIMULATION_H
    #define SIMULATION_H
    class Queue;
    class EventList;
    class PlaneList;
    
    using namespace std;
    
    
    class Simulation
    {
    	private:
    		//variables describing current status of the simulation
    		//these are altered by events (planes arriving and
    		//leaving), including flags for runway status
    		static int planesOnGround;
    		static bool isLandRunwayFree;
    		static bool isTakeoffRunwayFree;
    
    
    	public:
    
    		//queues for landing and departing flights!
    		static Queue* landingQ;
    		static Queue* takeoffQ;
    
    		//also need a list of planes and a list of events
    		static EventList* eventList;
    		static PlaneList* planeList;
    
    		//parameters for the simulation, things we might want
    		//to change in future runs
    		//you should always think ahead and try to parameterize
    		//things!
    		static const int MAX_PLANES=4; //max # planes on ground @ once
    		static const int LANDING_DELAY=5; //time delay for landing op
    		static const int TAKEOFF_DELAY=5; //time delay for takeoff op
    
    
    		//methods to alter the state of the simulation
    
    		//planesUp: increase the number of planes indicated
    		//as being on the ground.
    		static void planesUp();
    
    		//planesDown: decrease the number of planes indicated
    		//as being on the ground.
    		static void planesDown();
    
    		//return the number of planes currently on the ground
    		static int getPlaneCount();
    
    		//access methods for runway flags: two for retrieving
    		//their values, and methods that allow us to set and clear
    		//each of these flags.
    		static bool landRunwayFree();
    		static bool takeoffRunwayFree();
    		static void setLandRunwayOccupied();
    		static void setLandRunwayFree();
    		static void setTakeoffRunwayOccupied();
    		static void setTakeoffRunwayFree();
    
    };
    
    
    #endif
    //---------------------------------------------------------------
    // CLASS: Simulation
    //
    // REMARKS: methods and initializer for static values
    //
    // INPUT: none
    //
    // OUTPUT: none
    //
    //-----------------------------------------
    
    #include<iostream>
    #include "Simulation.h"
    #include "PlaneList.h"
    #include "Queue.h"
    #include "EventList.h"
    
    	int Simulation::planesOnGround = 0;
    	bool Simulation::isLandRunwayFree = true;
    	bool Simulation::isTakeoffRunwayFree = true;
    
    	PlaneList* Simulation::planeList = new PlaneList();
    	EventList* Simulation::eventList = new EventList();
    	Queue* Simulation::landingQ = new Queue();
    	Queue* Simulation::takeoffQ = new Queue();
    
    
    
    	//planesUp: increase the number of planes indicated
    	//as being on the ground.
    	void Simulation::planesUp()
    	{
    		Simulation::planesOnGround++;
    	}
    
    	//planesDown: decrease the number of planes indicated
    	//as being on the ground.
    	void Simulation::planesDown()
    	{
    		Simulation::planesOnGround--;
    	}
    
    	//return the number of planes currently on the ground
    	int Simulation::getPlaneCount()
    	{
    		return Simulation::planesOnGround;
    	}
    
    	//access methods for runway flags: two for retrieving
    	//their values, and methods that allow us to set and clear
    	//each of these flags.
    	bool Simulation::landRunwayFree()
    	{
    		return isLandRunwayFree;
    	}
    
    	bool Simulation::takeoffRunwayFree()
    	{
    		return isTakeoffRunwayFree;
    	}
    
    	void Simulation::setLandRunwayOccupied()
    	{
    		isLandRunwayFree = false;
    	}
    
    	void Simulation::setLandRunwayFree()
    	{
    		isLandRunwayFree = true;
    	}
    
    	void Simulation::setTakeoffRunwayOccupied()
    	{
    		isTakeoffRunwayFree = false;
    	}
    
    	void Simulation::setTakeoffRunwayFree()
    	{
    		isTakeoffRunwayFree = true;
    	}
    //---------------------------------------------------------------
    // CLASS: PlaneList header
    //
    // REMARKS: list of planes
    //
    // INPUT: none
    //
    // OUTPUT: none
    //
    //-----------------------------------------
    
    #ifndef PLANELIST_H
    #define PLANELIST_H
    
    #include "OrderedList.h"
    
    class Object;
    
    using namespace std;
    
    class PlaneList : public OrderedList
    {
    	private:
    
    	public:
    		PlaneList()
    		{
    			setFirst(NULL); //empty list to start!
    		};
    
    		bool smaller(Object* listItem, Object* newData);
    };
    
    #endif
    
    
    
    
    // CLASS: PlaneList
    //
    // REMARKS: abstract smaller method PlaneList must use
    //
    // INPUT: objects smaller is comparing
    //
    // OUTPUT: none
    //
    //-----------------------------------------
    
    #include <iostream>
    #include "PlaneList.h"
    #include "Plane.h"
    #include "Simulation.h"
    
    
    
    
    bool smaller(Object* listItem, Object* newData)
    {
    	//is the listItem smaller than the new data?
    	//the abstract list these are from is a list of Objects, so
    	//we need to cast them back to Planes.
    
    	bool result;
    	//plane 1 is smaller than plane 2 if it has a lower flight number
    
    	if ( ((Plane*) listItem)->getFlightNum() < ((Plane*) newData)->getFlightNum() )
    		result=true;
    	else
    		result= false;
    	return result;
    }

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    34
    Private member functions in PlaneList?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21