C++ Habits

Monday, April 18, 2005

I came to the conclusion this week that I have at least one C++ habit I can’t kick. When I want to check an object reference for null, my fingers automatically type:

Widget woo = GetWidgetFromSomewhere();



    // …


     Error: Cannot implicitly convert Widget to bool.

After five years of working together, the compiler still doesn’t understand me.

mitchell@4guysfromrolla.com (Scott Mitchell) Wednesday, April 20, 2005
When looking at others' code if I see comparing to 0 on the left, that's a sign (to me) that they did C/C++ work at one time. I.e.,
<br>if (0 == x) { ... }
<br>as opposed to:
<br>if (x == 0) { ... }
<br>Scott Mitchell
Brendan Tompkins Thursday, April 21, 2005
I for one would LOVE for the C# compiler to support this syntax. I'm with you brother.
Comments are closed.

My Pluralsight Courses

K.Scott Allen OdeToCode by K. Scott Allen
What JavaScript Developers Should Know About ECMAScript 2015
The Podcast!