2

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?

1 Answers1

4

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++

Community
  • 1
  • 1
gdlmx
  • 6,479
  • 1
  • 21
  • 39