syntax highlight

Tuesday, 18 August 2009

C++ oddities: Self initialization

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?

No comments:

Post a Comment