C++ oddities: Self initialization

Post by Nico Brailovsky @ 2009-08-18 | Permalink | Leave a comment

I get it, C++ is a complex language, but man, I'd like a little warning (lol) when this happens:

class Foo {
  int bar;
  Foo() : bar(bar) {}
};

Yeah, it bit me in the ass the other day. Why? A method's signature was awfully long, I wanted to delete a parameter and ended up deleting two. Luckly my unit tests where there to save the day, but regardless, WTF?