Using an STL List Object

I want to create a queue list in C ++, but the compiler gives me some cryptic messages:

#include <list> #include <queue> class Test { [...] list<queue> list_queue; [...] } 

Conclusion:

 error C2143: syntax error : missing ';' before '<' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C2238: unexpected token(s) preceding ';' 

This gives me the same error even if I use int as a template template. What's happening?

(btw, I am using VC ++ 2008 EE)

+4
source share
2 answers

queue also a template class, so you need to specify the type of element contained in your queues. In addition, - not a symbol of a legal identifier in C ++; Did you mean _ ?

 std::list<std::queue<SOME_TYPE_HERE> > list_queue; 
+8
source

also "using namespace std", and after defining your class, there should be a semicolon

280Z28 is right that โ€œuseโ€ in the header file is a bad idea for production code. However, it is still a smart troubleshooting step to quickly see if the underlying problem is the identifier search area.

+1
source

Source: https://habr.com/ru/post/1302819/


All Articles