Defining a pointer to a list in C ++

I am new to C ++ programming and am having trouble trying to define a pointer to a list. This is the code I'm trying to use:

list<int>* pl; 

Error:

 /home/julian/Proyectos Code::Blocks/pruebas/main.cpp|17|error: expected type-specifier before 'list'| 

Is it possible to define a pointer to a list? I need to have a function that returns a pointer to a list.

Many thanks

+6
source share
3 answers

You must include the list header and name list :

 #include <list> std::list<int> *p; 

As an alternative:

 using std::list; list<int> *p; 
+11
source

list is in the std . So try to do -

 std::list<int>* pl; 
+3
source

Try the following:

 std::list<int>* pl; 
+1
source

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


All Articles