For some reason g++ doesn't recognize unique_ptr in my code. Here the code:
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
unique_ptr<int> pInt( new int(42) );
return 0;
}
Here is the compilation command
g++ main.cpp -std=c++11 -o main
Here are the errors:
main.cpp: In function ‘int main(int, char**)’:
main.cpp:5:3: error: ‘unique_ptr’ was not declared in this scope
unique_ptr<int> pInt(new int);
^
main.cpp:5:14: error: expected primary-expression before ‘int’
unique_ptr<int> pInt(new int(42));
^
And here is the version of the compiler I'm using:
$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
What am I missing?
Aucun commentaire:
Enregistrer un commentaire