More Notes on “Effective C++”

18 April, 2009 § 2 Comments

This is a continuation of a previous post that I started after I finished reading Effective C++ by Scott Meyers.

Item 27: Minimize casting.
It’s hard to minimize casting, so when you do have to cast, you should use the C++-style casts instead of C-style casts. The C++-style casts have distinct purposes and allow the compiler to notice incorrect usage that the C-style casts don’t show.

Item 28: Avoid returning “handles” to object internals.
If you are returning a private member variable by reference from a public function, you’ve just opened up an entry point for that private member variable to be modified without your approval. Anytime you return a private member variable, you should return it by const-reference.

Item 34: Differentiate between inheritance of interface and inheritance of implementation.
The easiest way to differentiate between interfaces and implementations is to declare your interfaces with a naming convention like IInterface. This way you can clearly see that a class is enumerable becuase it implements IEnumerable, yet if the class inherits SortedArray, then you know that it extends an implementation of a SortedArray.

Tagged: ,

§ 2 Responses to More Notes on “Effective C++”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading More Notes on “Effective C++” at JAWS.

meta

Follow

Get every new post delivered to your Inbox.

Join 99 other followers