This is by far one of the best c++ programming posts I have ever read…. Thank you I am quoting this in my blog
http://prasansdevblog.blogspot.com
This is by far one of the best c++ programming posts I have ever read…. Thank you I am quoting this in my blog
I'm very pleased you liked it. I look forward to reading what you think about it.
I'm a bit confused by the third code example. When does this resolve to false:
if ( nLat < 180. || nLat >= 180. )
I'm not sure about this… isn't this writing a lot of code just to avoid writing a getter/setter pair? The containing class is easier to read, but to understand the class as a whole you can no longer read just one file.
I think that depends on how common the idiom is in the source code. For example, we don't worry about having to look up things like std::map or std::pair — we just use them and expect anybody reading the code to know what they are. The parts of the libraries that get used a lot need to be learned by the developers and when that happens the shorter class definitions are well worth it.
I don't think that the technique has much merit if not used pretty widely.
if ( nLat < 180. || nLat >= 180. )
I stared at this for many minutes thinking “there's nothing wrong there, what does he mean?” before I spotted the missing minus on the first half of the test. Thanks for spotting that.