effective-c++ Questions

2

Solved

In the book "Effective Modern C++" by Scott Meyers the advice is given (item 26/27) to "Avoid overloading on universal references". His rationale for this is that in almost all ...
Impostor asked 23/4, 2022 at 22:39

2

Solved

The final example at page 137 of Effective Modern C++ draws the scenario of a data structure with objects A, B, and C in it, connected to each other via std::shared_ptr in the following way: std::...
Avoidance asked 19/11, 2020 at 8:40

5

I have a quick question about item 48 in Scott Meyers' "Effective C++". I just don't understand the code copied from the book below, #include <iostream> using namespace std; template &lt...
Photopia asked 11/8, 2012 at 18:26

1

Solved

In effective c++, item 35, the author introduces the strategy pattern via function pointers. Specifically on page 172 class GameCharacter; int defaultHealthCalc(const GameCharacter& gc)...
Amphithecium asked 26/7, 2018 at 19:35

4

Solved

I decided to ask this question after reading items 20 and 22 of the book "More Effective C++" by Scott Meyers. Let's say you wrote a class to represent rational numbers: class Rational { public...

5

Solved

Recently, I read the book Effective C++ and there is a declaration about typedef in Item 35 which confuses me. class GameCharacter; // Question1: Why use forward declaration? int defaultHealthCal...
Badlands asked 12/3, 2017 at 8:54

3

Solved

In the book Effective C++, I saw the passage below: As a result, if you write class Empty{}; it's essentially the same as if you'd written this: class Empty { public: Empty() { ... } E...
Sulphurous asked 23/8, 2016 at 6:23

1

Solved

I understand that More Effective C++ is an expansion of Effective C++, while Effective Modern C++ focuses on C++11 & 14. Being a newbie to the language and just starting out with these bo...
Cajeput asked 7/1, 2016 at 3:26

3

In Effective C++ (3rd Ed.), Item 2 (Prefer const, enum and inline to #define), the code segment for class-specific constants read: class GamePlayer { private: static const int NumTurns = 5; // co...
Kati asked 6/1, 2016 at 9:42

1

Solved

Effective Modern C++ (page 136) uses the following example to motivate std::weak_ptr. A cache is defined as an unordered map with weak pointers to objects as values. Whenever clients of this cache ...
Ruffner asked 19/7, 2015 at 15:45

1

I was reading Effective C++, 3rd edition and in item 2 (prefer const, enums, and inlines to #defines), Scott Meyers mentions the symbol table: he explains that #defines may not appear in the symbol...
Voyeur asked 22/10, 2014 at 19:38

4

Solved

I've recently bought the new Effective modern C++ from Scott Meyers and reading through it now. But I have encountered one thing which totally bugs me. In item 5, Scott says that using auto is a g...
Objection asked 1/9, 2014 at 13:45

5

Solved

The following code works but I would like to avoid the warning: warning: 'fitness::vect_' should be initialized in the member initialization list [-Weffc++] when it is compiled with the g++ -...
Rase asked 24/2, 2014 at 16:47

7

Solved

int main( const int argc , const char[] const argv) As Effective C++ Item#3 states "Use const whenever possible", I start thinking "why not make these 'constant' parameters const"?. Is there any...
Frampton asked 13/12, 2013 at 3:9

3

Solved

From what I saw in this post I decided to start reading the book Effective C++. But now that there are many new features because of C++11 and that a few of the good practices changed, I'm not sure...
Spindry asked 25/7, 2013 at 19:10

6

Effective C++ by Scott Meyers tells in Chapter 5, Item 28 to avoid returning "handles" (pointers, references or iterators) to object internals and it definitely makes a good point. I.e. don't do t...
Ceporah asked 1/11, 2012 at 12:8

3

Solved

Our project uses a macro to make logging easy and simple in one-line statements, like so: DEBUG_LOG(TRACE_LOG_LEVEL, "The X value = " << x << ", pointer = " << *x); The macro t...
Diplocardiac asked 12/3, 2012 at 13:31

5

Solved

Good day! In his "Effective STL" Scott Meyers wrote A third is to use the information in an ordered container of iterators to iteratively splice the list's elements into the positions you'd like ...
Partan asked 9/2, 2012 at 23:47

4

Solved

I'm reading Effective C++ and came across this example: class Window { // base class public: virtual void onResize() { ... } // base onResize impl ... }; class SpecialWindow: public Window { //...
Derangement asked 31/1, 2012 at 18:23

3

Solved

In Scott Meyers's Effective C++, item 18 Make interfaces easy to use correctly and hard to use incorrectly, he mentioned the null shared_ptr: std::tr1::shared_ptr<Investment> pInv(static_cas...
Monongahela asked 28/7, 2011 at 21:45

5

Solved

I was reading Scott Meyers' Effective C++ (third edition), and in a paragraph in Item 32: Make sure public inheritance is "is-a" on page 151 he makes the comment (which I've put in bold): This i...
Wow asked 26/6, 2011 at 13:41

2

Solved

In this chapter Scott Meyer mentioned a few technique to avoid header files dependency. The main goal is to avoid recompiling a cpp file if changes are limited to other included header files. My q...
Baton asked 12/6, 2011 at 11:28

7

Solved

While puzzling with some facts on class design, specifically whether the functions should be members or not, I looked into Effective c++ and found Item 23, namely, Prefer non-member non-friend func...

4

Solved

In Effective C++ (3rd edition), Scott Meyers, in Item 31, suggests that classes should have, on top of their classic Declaration (.h) and Definition (.cpp) files, a Forward Declaration Include File...
Electroluminescence asked 14/10, 2010 at 16:3

4

Solved

A static check tool shows a violation on the below code: class CSplitFrame : public CFrameWnd ... class CVsApp : public CWinApp CWnd* CVsApp::GetSheetView(LPCSTR WindowText) { CWnd* pWnd = reint...
Chatelain asked 30/9, 2010 at 15:56

© 2022 - 2024 — McMap. All rights reserved.