Reputation:
I am new to c++. In a tutorial i was reading about auto
and decltype
and tried the following:
#include <iostream>
using namespace std;
int foo = 0;
decltype(foo) bar;
bar = 22;
int main(){
cout<<foo;
cout<<bar;
}
and i get this error upon compilation:
tst.cpp.6:1: warning: identifier 'decltype' is a keyword in C++11
Why is this happening?
Upvotes: 3
Views: 354
Reputation: 6789
You need to add -std=c++11
flag (command line argument) to your compiler:
g++ -std=c++11 tst.cpp -o your_program_name.exe
For more reading: Compiling C++11 with g++
Upvotes: 5