auto Keyword

Hello!
I'm just going to ask you guys a simple question, I was reading about the "auto" keyword, but when I tried it out it did not seem to work, and I don't really know why. Do you know why? Is there some command at the beginning that I forgot to include? My code is down below. BTW, this program isn't such a big deal to me, I was just testing if it worked like in the book I was reading.

1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;

int main(){
    auto course = 0.0;
    auto days = 0;
    const auto tax = 10;
    cout << kurs;
    return(0);
}


"Code::Blocks", the IDE which I am using, gave me these errors:

Line 5: "auto" changes meaning in C++11; please remove it [-Wc++0x-compat]
error: "course" does not name a type

And it basically gave me the same errors for all variables.
Last edited on
Your compiler is not in C++11 mode.
add -std=c++0x to compiler options

EDIT: settings → compiler and debugger → check "have g++ follow the coming C++0x standard"
Last edited on
It works now! Thanks a lot :)
Topic archived. No new replies allowed.