Nicolás Brailovsky


A modern blog

C++ oddities: Self initialization

author Posted by: nico on date Aug 18th, 2009 | filed Filed under: C++, Programming
I get it, C++ is a complex language, but man, I’d like a little warning (lol) when this happens:

  1. class Foo {
  2.   int bar;
  3.   Foo() : bar(bar) {}
  4. };
cpp

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?

     Add A Comment

trackback Trackback URI | rsscomment Comments RSS