I'm trying to use brace-initialization notation:

int number{}; 

But I get the following error: "expected an expression". Shouldn't c++11 allow this kind of initialization?

int number2(4)

works just fine.

Thank you.

Edited 2 Years Ago by Cave_1

What compiler are you using? MSVS 2013 does not have an issue with it. Also if you want to intialize number with 4 using braces you would use int number{4};


I'm usuing Visual Studio 12 with latest updates on Win7.

I tired

int number{4};

too, and still nothing.

Edited 2 Years Ago by Cave_1

Are you using Visual Studio 2012? I don't know of a Visual Studio 12 unless you are talking about version 12. If you go to Help -> About you will get a window like the attached. Post it here.

Edited 2 Years Ago by NathanOliver

Attachments about.png 59.55 KB

You are running Visual Studio 2012 which is version 11. version 11 has little to no c++11 support. You need to go to version 2013 update 3 to get te best support that Microsoft offers.

This question has already been answered. Start a new discussion instead.