I am having trouble, Whenever I try to compile this program I get an error in the contains function where it says q.pop. If that line is commented out it will compile fine, but it stills gives the wrong value. It is always false for some reason. 

The error is:  

`priority_queue_demo.cpp: In function 'int main()':
priority_queue_demo.cpp:54:12: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
/usr/lib/gcc/x86_64-redhat-linux/4.6.1/../../../../include/c++/4.6.1/bits/basic_string.tcc:214:5: error: initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' [-fpermissive]
priority_queue_demo.cpp: In function 'bool contains(const std::priority_queue<T>&, T) [with T = int, typename std::vector<T, std::allocator<_Tp1> >::value_type = int]':
priority_queue_demo.cpp:43:47: instantiated from here
priority_queue_demo.cpp:27:3: error: passing 'const std::priority_queue<int>' as 'this' argument of 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = int, _Sequence = std::vector<int, std::allocator<int> >, _Compare = std::less<int>]' discards qualifiers [-fpermissive]`

```
#include <iostream>
#include <string>
#include <sstream>

#include <queue>

using namespace std;

template <typename T>
ostream &operator <<(ostream &os, priority_queue<T> &q) {
        os << "{";
        while (!q.empty()) {
               os << q.top() << (!q.empty() ? ", " : "");
               q.pop();
        }

        os << "}";

        return os;
}

template <typename T>
bool contains(const priority_queue<T> &q, T val) {
        for (int i = 0; i < q.size(); i++) {
                if (q.top() == val) return true;
                q.pop();
        }

        return false;
}

int main() {
        cout << boolalpha;

        priority_queue<int> qi;

        for (int i = 0; i < 20; i++)
                qi.push(i);

        cout << qi << endl;

        cout << "qi contians 15: " << contains(qi, 15) << endl;
        cout << "qi contians 23: " << contains(qi, 23) << endl;

        const int ARR_SIZE = 4;
        string arr[ARR_SIZE] = {"cat", "dog", "cow", "elephant"};

        cout << endl;

        priority_queue<string> qs;

        for(int i = 0; i < ARR_SIZE; i++)
                qs.push(i);

        cout << qs << endl;

        while(!qs.empty()) {
                qs.pop();
                cout << qs << endl;
        }

        return 0;
 }

```