I am new to c++, and I am trying to get a basic program to initialize a list of short unsigned integers. I am compiling and running using scygwin and g++.
Below is the code in the .cpp file:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <typeinfo>
using namespace std;
int main (int argc, char* argv[]) {
list<int> events;
return 0;
}
which I run by typing the following command into cygwin terminal:
$ g++ -o test.out test.cpp
However, I get the following compilation errors:
test.cpp: In function ‘int main(int, char**)’: test.cpp:16:1: error: ‘list’ was not declared in this scope list events;
^ test.cpp:16:6: error: expected primary-expression before ‘int’ list events; ^
I am confused about why list is not in the scope, since I am using namespace std? I found a similar question asked about this on a c++ forum, but my problem would be resolved with that. Anyone know what the problem is here?
-Paul
– AndyG Jun 24 '16 at 21:23
is hidden within namespace std until I explicitly include it? I guess I have been assuming that there is always an implicit `#include` in every c++ file, which would give you access to anything in that namespace.
– Paul Jun 24 '16 at 21:40