Search code examples
visual-c++visual-c++-2010

error: identifier "list" is undefined (new to Visual C++)


I just want to initialize a List on Visual C++ but I am getting following errors:

  • error: identifier "list" is undefined
  • error C2065: 'list' : undeclared identifier

why is this happening?

my includes:

#include "stdlib.h"
#include "malloc.h"
#include "stdio.h"
#include <set>
#include <vector>
#include <string>
#include <list>
#include "stdafx.h"
#include <iostream>
#include <io.h>
#include <fcntl.h>
#include <fstream>
#include <WebServices.h>
#include "./WCF_managed_app.xsd.h"
#include "./WCF_managed_app_Client.wsdl.h"
#include "./WCF_managed_app_Client.xsd.h"
#include "./schemas.microsoft.com.2003.10.Serialization.xsd.h"

Solution

  • you probably have forgotten the using namespace std; in your cpp file so as to have access to the definition of list that resides into the std namespace.

    personnaly I prefer not to use using namespace std;

    and I use std::list rather of list in my cpp files

    std::list<Element> myList;
    myList.push_back(anElement);