Jason A.
Jason A.

Reputation: 71

Defining a constructor of a private class

Queue and airportSim classes are defined.

class Queue
{
    public:
       Queue(int setSizeQueue = 20);

    //Queue's contents
}

class airportSim
{
    public:
       airportSim(int setSizeRunway = 20);

    private:
       Queue airQueue;
       Queue groundQueue;

    //Other airportSim contents.
}

Queue::Queue(int setSizeQueue)
{
   //Contents of airportSim constructor supposed to come here.
}

airportSim::airportSim(int setSizeRunway)
{
    airQueue(setSizeRunway);
    groundQueue(setSizeRunway);
}

It says it has trouble accessing the constructors. Anyone know how to define the constructor of the queues?

Upvotes: 0

Views: 102

Answers (1)

John Kugelman
John Kugelman

Reputation: 361635

Use the initialization list syntax:

airportSim::airportSim(int setSizeRunway)
    : airQueue(setSizeRunway),
      groundQueue(setSizeRunway)
{
}

Upvotes: 1

Related Questions