Feeds:
Posts
Comments

Archive for the ‘GotW’ Category

While spelunking through the code of a new project you recently joined, you find the following factory function declaration:   JG Question 1. What’s wrong with this return type?   Guru Questions 2. What is the recommended return type? Explain your answer, including any tradeoffs. 3. You’d like to actually change the return type to [...]

Read Full Post »

GotW #103: Solution

The solution to GotW #103 is now live.

Read Full Post »

JG Question 1. When should you use shared_ptr vs. unique_ptr? List as many considerations as you can.   Guru Questions 2. Why should you always use make_shared to allocate objects whose lifetimes will be managed by shared_ptr? Explain. 3. What’s the deal with auto_ptr?

Read Full Post »

GotW #102: Solution

The solution to GotW #102 is now live.

Read Full Post »

JG Question 1. In each of the following statements, what can you say about the order of evaluation of the functions f, g, and h and the expressions expr1 and expr2? Assume that expr1 and expr2 do not contain more function calls. Guru Questions 2. In your travels through the dusty corners of your company’s [...]

Read Full Post »

GotW #101: Solution

The solution to GotW #101 is now live.

Read Full Post »

GotW #100 demonstrated the best way to express the Pimpl idiom using only standard C++11 features: Guru Question Is it possible to make the widget code easier to write by wrapping the Pimpl pattern in some sort of library helper? If so, how? Try to make the widget code as convenient and concise as possible [...]

Read Full Post »

GotW #100: Solution

The solution to GotW #100 is now live.

Read Full Post »

JG Questions 1. What is the Pimpl Idiom, and why is it useful? Guru Questions 2. What is the best way to express the basic Pimpl Idiom in C++11? 3. What parts of the class should go into the impl object? Some potential options include: put all private data (but not functions) into impl; put [...]

Read Full Post »

Follow

Get every new post delivered to your Inbox.

Join 886 other followers