Following the tutorials for auto;
why this code can't compile?
error: 'bar' does not name a type
1 2 3 4 5 6 7 8 9
|
#include <iostream>
using namespace std;
int main(){
int foo = 0;
auto bar = foo; // the same as: int bar = foo;
}
|
Last edited on
Are your compiler recent enough and have you enabled features for C++11 (or later)?
Last edited on
I'm using gcc 4.8.1. How can I check this feature is enabled?
Use command line flag: -std=c++11
See 'man gcc'
Is this the command "flag: -std=c++11" ?
got an error that can't recognize!
I'm using IDE but I tried with "g++ -std=c++11 -O2 -Wall -pedantic"
on command line still following error:
warning: unused variable 'bar' [-Wunused-variable]
You right but still not complied! Should be compiled, Isn't it?
Last edited on
Actually it's text editor(sublime). I deleted the related compiled file(.exe) to make
sure if the new one compiled.