2011-10-04 198 views
0

定義隊列和airportSim類。定義私有類的構造函數

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); 
} 

它說它無法訪問構造函數。任何人都知道如何定義隊列的構造函數?

回答

1

使用initialization list語法:

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

真棒。忘記了那個神奇的代碼!非常感謝! –

相關問題