Reputation: 1
I am having some issues passing a queue as a parameter to a function in C++
I have an STL queue defined queue<int> example[100];
I have a function defined void calculateSum(queue<int> &example, int size){}
I am trying to pass the queue to this function by writing calculateSum(example, 100)
but I keep getting an error saying [cquery] no matching function for call to 'minimumDistance'
What should I do? Any feedback would be helpful
Upvotes: 0
Views: 1474
Reputation: 596
queue<int> example[100];
will create an array (named example
) of queues. Your function, void calculateSum(queue<int> &example, int size)
, accepts a reference to a single queue of ints (not an array of queues).
Assuming you do in fact want an array of queues, and you do want that function to accept a reference only to a single queue, you must choose one of the queues from your array to pass into it. For example, you could do calculateSum(example[0], 123);
to pass in the first queue in your array.
Upvotes: 0
Reputation: 1551
Your declaration queue<int> example[100];
makes an array of 100 queues.
What you probably want is just queue<int> example;
and then let it grow as you add elements.
Upvotes: 1