Talk:C++ Programming/Idioms

I'd initially thought this page will have short examples for quick reference of syntax as this page was supposed to be a continuation of Programming:C plus plus Reference Tables which is already a bit large. Specific examples like the Temperature class should probably go into the main text (i.e. the portion of the textbook not including appendices like reference tables, glossary, FAQ). But until we get chapters on constructors, it could be retained here. With this hindsight, probably even the long explanation on why prevention of copying might be necessary, and other such things that I wrote should also go to the main text.

BTW We could have separate pages for each section in the reference tables page, and probably have a page transcluding all those pages. Also some of the bloat in those tables could also be transferred to the main text.

Note that I am still under the assumption that we'd have a textbook spanning multiple modules. -- Paddu 12:47, 16 Nov 2004 (UTC)

About pImpl example
Somehow I think using templates it would be more efficient to implement the pImpl example, although you wouldn't be able to use different implementations at run-time, you'd still get the same result with no need for memory management (new & delete). Changed to something like this...

template  class Book { public: void print; private: l_BookImpl m_p; } void Book::print {  m_p.print; }

The only difference here is the  instead of   (and the lack of new in ctor and the implied delete in dtor), the latter of which also would require something to pass another implementation in order to actually benefit from the pointer usage, which the example lacks completely.

--Acolyte of Discord 00:05, 25 April 2007 (UTC)

A discussion of almost exactly this idea appeared in . 105.227.117.134 (discuss) 20:05, 19 February 2015 (UTC)

pImpl section introduction
"In C++ you have to declare member variables within the class definition which is then public and that this is necessary so that an appropriate memory space is allocated means that abstraction of implementation is not possible in "all" classes."

This paragraph is really awkward and should be re-written. Unfortunately I am not knowledgeable enough to do that myself. --Aptd (discuss • contribs) 18:24, 3 August 2016 (UTC)