I need help printing a queue in a header.h file.
for example: this works just fine:
main.cpp
void showq(queue<int> gq)
{
queue<int> g = gq;
while (!g.empty()) {
cout << '\t' << g.front();
g.pop();
}
cout << '\n';
}
int main()
{
queue<int> gquiz;
gquiz.push(10);
gquiz.push(20);
gquiz.push(30);
showq(gquiz);
return 0;
}
Output: 10 20 30
but this does not
main.cpp
int main()
{
queue<int> gquiz;
gquiz.push(10);
gquiz.push(20);
gquiz.push(30);
showq(gquiz);
return 0;
}
header.h:
void showq(queue<int> gq)
{
queue<int> g = gq;
while (!g.empty()) {
cout << '\t' << g.front();
g.pop();
}
cout << '\n';
}
Output: error: variable or field showq declared void