Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class Problems

Status
Not open for further replies.

Azathoth

Technical User
Jul 14, 2003
61
US
When trying to construct a class object containing another class object, I get the error:

"no matching function call to "PlaneId::planeId
candidates are: pLaneId::planeId(const PlaneId&)
PlaneId::planeId(const std::string&, int)"

Here are my two class files:

Code:
//  File:  Planes.h

#ifndef Planes_h_
#define Planes_h_

#include "PlaneId.h"

enum PlaneStatusType { UNASSIGNED, IN_RANGE, IN_LANDING_QUEUE, IN_TAKEOFF_QUEUE, LANDED, 
		       TOOK_OFF, EMERGENCY, CRASHED };

class LandingPlane {
 public:
  LandingPlane( PlaneId const& id, int scheduled_minute, int minutes_until_arrival,
		int fuel_minutes_remaining, int num_passengers )
  { m_id = id; m_scheduled_minute = scheduled_minute;
    m_minutes_until_arrival = minutes_until_arrival;
    m_fuel_minutes_remaining = fuel_minutes_remaining;
    m_passengers = num_passengers; }
  
  PlaneId const& id() const { return m_id; }
  PlaneStatusType status() const { return m_status; }
  int scheduled_minute() const { return m_scheduled_minute; }
  int on_ground_minute() const { return m_landed_or_crashed_minute; }
  int minutes_until_arrival() const { return m_minutes_until_arrival; }
  int fuel_minutes_remaining() const { return m_fuel_minutes_remaining; }
  int runway_number() const { return m_runway; }
  int minutes_in_queue() const { return m_in_queue_minutes; }
  int num_passengers() const { return m_passengers; }
  int delay() const { return m_landed_or_crashed_minute - m_scheduled_minute; }

  void increment_minute( );
  void assign_to_runway( int runway_number );
  void land_plane( int minute );
  void crash_plane( int minute );

 private:
  PlaneId m_id;
  PlaneStatusType m_status;
  int m_scheduled_minute;
  int m_landed_or_crashed_minute;
  int m_passengers;

  int m_minutes_until_arrival;
  int m_fuel_minutes_remaining;
  int m_in_queue_minutes;
  
  int m_runway;
};
Code:
//  File:    PlaneId.h

#ifndef PlaneId_h_
#define PlaneId_h_

#include <string>
using namespace std;

class PlaneId {
 public:
  PlaneId( string const& airline, int number ) 
  { m_airline = airline; m_number = number; }
  string const& airline() const { return m_airline; }
  int number() const { return m_number; }
  void set_airline(string a) { m_airline = a; }
  void set_number(int n) { m_number = n; }

 private:
  string m_airline;
  int m_number;
};

bool operator< ( PlaneId const& p1, PlaneId const& p2 )
{ return p1.number() < p2.number(); }

bool operator== ( PlaneId const& p1, PlaneId const& p2 )
{ return p1.number() == p2.number(); }

#endif

I get this error without even attempting to create an instance of the object...any ideas?
 
Apparently I just needed a default constructor in PlaneId...disregard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top