Variable initialization

I am reading a beginners C++ book where they show that under C++11, a variable my be defined and initialized as follows:

int age{54};

When I try this in a console program with Visual Studio Express 2013, it causes errors unless I add the equal sign like this:

int age = {54};

Am I misunderstanding this or doing something wrong?
closed account (S6k9GNh0)
What book?
Also, perhaps you're mistaking it with parenthesis.

int age(54); is valid.
Last edited on
Computerquip:

Thanks for responding. The book is C++ Primer Plus 6th edition by Stephen Prata. It is very specific about the use of curly braces. The funny thing is that it failed using Visual Studio Express 2013 BUT it worked using DevC++.
Topic archived. No new replies allowed.