Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining a pointer to a list in C++

Tags:

c++

list

pointers

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

list<int>* pl;

The error:

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

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

Thank you very much

like image 767
Julián Muriel Tejo Rodríguez Avatar asked Feb 07 '12 20:02

Julián Muriel Tejo Rodríguez


3 Answers

You have to include the list header and qualify the name list:

#include <list>

std::list<int> *p;

Alternatively:

using std::list;
list<int> *p;
like image 115
cnicutar Avatar answered Oct 17 '22 03:10

cnicutar


list resides in std namespace. So try doing -

std::list<int>* pl; 
like image 30
Mahesh Avatar answered Oct 17 '22 01:10

Mahesh


Try the following:

std::list<int>* pl;
like image 1
hatboyzero Avatar answered Oct 17 '22 01:10

hatboyzero