开发者

Defining a constructor of a private class

开发者 https://www.devze.com 2023-04-10 16:36 出处:网络
Queue and airportSim classes are defined. class Queue { public: Queue(int setSizeQueue = 20); //Queue\'s contents

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 sup开发者_高级运维posed 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?


Use the initialization list syntax:

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

精彩评论

暂无评论...
验证码 换一张
取 消