0

My first question on here so please be gentle! Appologies if this has already been asked/answered, but a search didn't bring anything up. It's a question of curiosity:

Let's say we have a private variable called 'fred'. It the constructor we could initialize it as:

ClassName::ClassName(input params) : fred(0) ....

Inside the body of some code we could use curly braces:

fred{0};

Or we could use the traditional C assignment:

fred = 0;

My question is; is there any functional different? Or is it just style preference?

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Is [this post](https://stackoverflow.com/questions/18222926/why-is-list-initialization-using-curly-braces-better-than-the-alternatives) answers your question? – dlivshen Oct 02 '21 at 11:59
  • Thanks for the link. Helpful and goes some way towards answering my question. – Todd Dowty Oct 04 '21 at 10:44

0 Answers0