Nayana Adassuriya
Nayana Adassuriya

Reputation: 24766

How to set the size of STL queue in class constructor

A class has a queue and I need to set the queue size in the constructor of the class. Is this possible?

Just an idea what I want to do:

class Test
{
  queue<int> age_queue;     
  Test(int queue_size):age_queue(queue_size){}
}; 

Upvotes: 1

Views: 1320

Answers (1)

Mankarse
Mankarse

Reputation: 40613

Try

class Test
{
  queue<int> age_queue;     
  Test(int queue_size):age_queue(deque<int>(queue_size)){}
};

Upvotes: 3

Related Questions