2

i've seen this in the code and it actually works,

class a
{
public:
    a(){}    
};
class b
{
public:
    b(){}
};
class c:public a,b
{
public:
    c():a{},b{}{}
};

So c():a{},b{} is the place confuses me, shouldn't it be c():a(),b() instead? Is that something new in C++11?

henryyao
  • 1,758
  • 6
  • 23
  • 37
  • 1
    It is new in C++11. Some prefer the curly-style initialization, because it supports a few features such as list-initialization and avoids narrowing. If that is a benefit or a wart is arguable. I like it; other developers do not. – Eljay Sep 14 '18 at 19:12
  • I love how coming up onto the end of 2019 we still have to say "new" when referring to the 2011 standard revision that has subsequently been replaced and the replacement replaced. I will use this as my single data point proof next time someone tells me the world is moving too fast. Thank you Stack Overflow for making me a more efficient and effective Internet Troll. – user4581301 Sep 14 '18 at 19:26
  • @user4581301 The sad fact is there is a number of people that are taught C++ that don't even know about C++03, let alone a major change like C++11. In some places they are still taught using the pre-standard TurboC++. – NathanOliver Sep 14 '18 at 19:27
  • Don't I know it. It often seems to be a struggle to get C++ taught as C++ and not as C. Based on the last round of hiring I did, it is getting better. It just doesn't *look* like it. Or maybe I got a outlier last round. Single data points suck. – user4581301 Sep 14 '18 at 19:31

0 Answers0