cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Variable initialization
Variable initialization
Aug 17, 2013 at 1:49am UTC
Truebluefliplover
(4)
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?
Aug 17, 2013 at 1:50am UTC
closed account (
S6k9GNh0
)
What book?
Also, perhaps you're mistaking it with parenthesis.
int
age(54);
is valid.
Last edited on
Aug 17, 2013 at 1:51am UTC
Aug 17, 2013 at 2:01am UTC
Truebluefliplover
(4)
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.