[try Beta version]
Not logged in

 
Small question about classes

Feb 13, 2015 at 11:33pm
i am looking at code for a custom vector class and i see something like this
1
2
3
4
  ClassName a;
  ClassName d{5};
  cout<< d


what is {5} and what the difference with d(5) the intent is to store one element ' 5' into a vector like class

thanks
Feb 14, 2015 at 1:08am
It is brace initialization.

http://en.cppreference.com/w/cpp/language/aggregate_initialization

It was added in C++11 and is preferred in many cases.
Last edited on Feb 14, 2015 at 1:08am
Feb 14, 2015 at 7:19pm
thanks just starting to learn all the new featured on c++11
Topic archived. No new replies allowed.