Discussing the nuts and bolts of software development

Thursday, August 23, 2007


Pay it Forward: Part 2

When writing C++ classes and interfaces (e.g. abstract classes), do your compiler a favor and declare each class in its own header file whenever you can. Trust me, it'll pay you back later.

Rule of thumb:
If you ever need to use the would-be nested class without using the nesting class, then your class should not be nested.
To see how nested classes should be used, look at std::string::iterator. It's a nested type (Okay, okay, it could be a nested typedef that could alias a non-nested class. From outside std::string, it looks like a nested class and that's all that matters.) that's useless without its nesting class std::string.

Now, here's an example of how not to use your nested types:


// Forward type declaration
class Contact; // Remember this?

class AddressBook
// Interface to be implemented by objects wanting AddressBook notifications.
class IContactEventSink
virtual void onContactChanged(Contact const& oldContact, Contact const& newContact) = 0;
With the the above implementation, whenever someone wants to receive notification from the AddressBook, they need to include the AddressBook itself and derive from AddressBook::IContactEventSink. Doing this has the following down sides:
To fix all of this and to give your compiler a break, declare the IContactEventSink class in its own header and include this header whenever you need the full definition.


// Forward type declaration
class Contact; // Yup, even here.

class IContactEventSink
virtual void onContactChanged(Contact const& oldContact, Contact const& newContact) = 0;
Then, hit "Build", sit back and wait to...

... actually no. You can get on with your life. Your incremental build is now done because you've paid it forward!

Labels: , , ,

On https://resumecvwriter.com/blog/how-to-write-resume-job-description you can read how to write resume job description. It will help you to get vocation
It is important to seek sociology paper writing services and sociology assignment writing services since students find help when they visit Sociology Essay Writing Services.

Those're the prefect cues for operating an Address books. Like, when I started receiving errors for my mini film project through word press. I even had to opt for the best law assignment writers to guide me the regulations for if a bought address book works poorly, and the consequences the developers have to face, Luckily, it all worked out just fine.
I have no idea about the Macadamian Files, but what I need from anyone here is It management assignment help because my knowledge of software system and programming is week, hence writing assignments on them is close to impossible because I lack conceptual understanding of this kind of technical courses
Wow!! This truly is an informative post!!
Thanks for sharing it!!
Insurance Quote Usaa

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the
commenters here! It’s always nice when you can not only be informed, but also entertained!

visit my blog:: 출장안마

Thanks for sharing this informative content, Great work.

To crack Scrum master interview: Scrum master interview questions
I gotta be honest here, it is not easy to create good content on your own, because sometimes we do lack the ability or the concentration to the accounting process. I did have these shortcomings, but no way I am letting that affect my grades, and this is why to Small Business Advisory Services, I hired someone professional.

Nice post, I love my tom and feed quality food to make active and create freshness from internal. s700 champion
Thank you for sharing this post with us. I learn more through your post. Further, It's time to avail of Dallas Mobile Locksmith.
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?