(Click here for a personal note from Marshall Cline.)
C++ FAQ
/
Section 4
/ FAQ 4.26
Section 4:
4.1
Updates for the 03/12 release?
New!
4.2
Updates for the 11/11 release?
New!
4.3
Updates for the 07/11 release?
4.4
Updates for the 05/11 release?
4.5
Updates for the 03/11 release?
4.6
Updates for the 08/10 release?
4.7
Updates for the 06/10 release?
4.8
Updates for the 05/10 release?
4.9
Updates for the 04/10 release?
4.10
Updates for the 03/10 release?
4.11
Updates for the 01/10 release?
4.12
Updates for the 09/09 release?
4.13
Updates for the 06/09 release?
4.14
Updates for the 01/09 release?
4.15
Updates for the 03/07 release?
4.16
Updates for the 09/06 release?
4.17
Updates for the 03/06 release?
4.18
Updates for the 10/05 release?
4.19
Updates for the 07/05 release?
4.20
Updates for the 06/05 release?
4.21
Updates for the 05/05 release?
4.22
Updates for the 04/05 release?
4.23
Updates for the 03/05 release?
4.24
Updates for the 02/05 release?
4.25
Updates for the 12/04 release?
4.26
Updates for the 06/04 release?
4.27
Updates for the 08/03 release?
4.28
Updates for the 06/03 release?
4.29
Updates for the 05/03 release?
4.30
Updates for the 04/03 release?
4.31
Updates for the 03/03 release?
4.32
Updates for the 02/03 release?
4.33
Updates for the 01/03 release?
4.34
Updates for the 12/02 release?
4.35
Updates for the 09/02 release?
4.36
Updates for the 06/02 release?
4.37
Updates for the 05/02 release?
4.38
Updates for the 04/02 release?
4.39
Updates for the 03/02 release?
4.40
Updates for the 08/01 release?
4.41
Updates for the 04/01 release?
4.42
Updates for the 07/00 release?
4.43
Updates for the 03/00 release?
4.44
Updates for the 01/00 release?
4.45
Updates for the 10/99 release?
4.46
Updates for the 07/99 release?
4.47
Updates for the 06/98 release?
4.48
Updates for the 05/98 release?
4.49
Updates for the 09/97 release?
4.50
Updates for the 01/97 release?
4.51
Updates for the 11/96 release?
4.52
Updates for the 10/96 release?
4.53
Updates for the 09/96 release?
4.54
Updates for the 08/96 release?
4.55
Updates for the 07/96 release?
4.56
Updates for the 06/96 release?
4.57
Updates for the 05/96 release?
4.58
Updates for the 04/96 release?
4.59
Updates for the 03/96 release?
4.60
Updates for the 09/95 release?
4.61
Updates for the 06/95 release?
4.62
Updates for the 04/95 release?
4.63
Updates for the 03/95 release?
4.64
Updates for the 01/95 release?
4.65
Updates for the 12/94 release?
4.66
Updates for the 11/94 release?
4.67
Updates for the 08/94 release?
4.68
Updates for the 08/94 release?
[4.26] What updates were made for the 06/04 release?
Polish translation:
The
Polish translation of the C++ FAQ
is now available thanks to the hard work of translators
Tomek Bywalec
,
Bartek Krzemien
and
Janek Pustelnik
. The translation isn't finished, but the translators deserve congratulations and thanks for what they've done so far.
16 New FAQs:
[2.11] Where can I find the C++ FAQ translated into Polish?
(created with much thanks to translators
Tomek Bywalec
,
Bartek Krzemien
and
Janek Pustelnik
)
[4.26] What updates were made for the 06/04 release?
(created)
[6.17] Is it important to know the technical definition of "good OO"? Of "good class design"?
(created)
[17.12] What should I throw?
(created thanks to
Carl Daniel
)
[17.13] What should I catch?
(created thanks to
Carl Daniel
)
[17.14] But MFC seems to encourage the use of catch-by-pointer; should I do the same?
(created thanks to
Carl Daniel
)
[17.15] What does
throw;
(without an exception object after the
throw
keyword) mean? Where would I use it?
(created thanks to
Carl Daniel
)
[17.16] How do I throw polymorphically?
(created thanks to
Carl Daniel
)
[17.17] When I throw this object, how many times will it be copied?
(created thanks to
Carl Daniel
)
[33.12] I need something like function-pointers, but with more flexibility and/or thread-safety; is there another way?
(created)
[33.13] What the heck is a functionoid, and why would I use one?
(created thanks to a question from
Christian Cuvier
)
[35.17] How can any human hope to understand these overly verbose template-based error messages?
(created thanks to gentle pestering from
Leor Zolman
)
[35.19] Why am I getting errors when my template-derived-class uses a member it inherits from its template-base-class?
(created thanks to
Daveed Vandevoorde
)
[35.20] Can the previous problem hurt me silently? Is it possible that the compiler will silently generate the wrong code?
(created thanks to
Daveed Vandevoorde
)
[39.15] Why do some people think
x = ++y + y++
is bad?
(created)
[39.16] What's the deal with "sequence points"?
(created)
32 Changed FAQs:
[2.6] Where can I find the C++ FAQ translated into Chinese?
(updated the URL for the GB-encoded translation thanks to
Imron Alston
)
[6.5] Is C++ better than Ada? (or Visual Basic, C, FORTRAN, Pascal, Smalltalk, or any other language?)
(added to the last paragraph to make it stronger(!!))
[6.13] Where can I get a copy of the ANSI/ISO C++ standard?
(rewrote from scratch, thanks to comments and corrections from
Petter Häggholm
,
Lars Christensen
,
Pieter Van Dyck
and
Jim Fischer
)
[6.15] What does the FAQ mean by "such and such is
evil
"?
(changed "such-in-such" to
"such and such"
thanks to
Darren Frith
and
Simon OLeary
)
[8.4] What does
object.method1().method2()
mean?
(removed a couple superfluous ")"s)
[10.3] Can one constructor of a class call another constructor of the same class to initialize the
this
object?
Updated!
(added a strong statement against using placement new in this situation thanks to questions from
Marc Page
and
Steve Peters
)
[10.6] Should my constructors use "initialization lists" or "assignment"?
(fixed a (subtle!) miswording in the second paragraph thanks to
Tomek Bywalec
,
Bartek Krzemien
and
Tian Yu
; added the stuff on exceptions (see last paragraph) thanks to
Alf Steinbach
)
[10.20] What is the "Named Parameter Idiom"?
(added a bunch more example code and clarified the explanation of
class OpenFile
thanks to
Tomek Bywalec
and
Bartek Krzemien
)
[12.1] What is "self assignment"?
(fixed an error in the code-comments thanks to
Jonathan Mcdougall
)
[13.10] How do I create a subscript
operator
for a
Matrix
class?
(fixed a typo thanks to
Doug Schwartz
)
[15.1] Why should I use
<iostream>
instead of the traditional
<cstdio>
?
(removed a superfluous ")")
[15.9] But shouldn't I always use a
printOn()
method rather than a
friend
function?
(removed a superfluous ")")
[15.17] How can I tell {if a key, which key} was pressed before the user presses the ENTER key?
(updated the URL thanks to
Sampath Patnala
)
[15.18] How can I make it so keys pressed by users are not echoed on the screen?
(fixed the title thanks to
Todd Catelotti
)
[16.6] Do I need to check for
NULL
after
p = new Fred()
?
(added a caveat for MSVC++ thanks to Graham Knap)
[20.8] What is a "
virtual
constructor"?
(rewrote the last paragraph for clarity)
[21.2] Converting
Derived*
→
Base*
works OK; why doesn't
Derived**
→
Base**
work?
(fixed a grammatical error thanks to
Philip S Tellis
)
[22.5] How do you define a copy constructor or assignment
operator
for a class that contains a pointer to a (abstract) base class?
(added a "contract" to the
Fred
ctor thanks to
Bo Majewski
; changed the return types in the derived classes to exploit covariant return types thanks to
Dan Raviv
)
[23.11] How can I set up my class so it won't be inherited from?
(fixed a bug in the
friend
declaration, renamed the classes to
Fred
and
FredBase
, and general wordsmithing)
[28.7] What are some best-of-breed C++
programming-by-example
guides?
(added details about Musser and Saini thanks to
Randy Sherman
)
[29.5] What are the criteria for choosing between
short
/
int
/
long
data types?
(added stuff about
<stdint.h>
thanks to
Oliver Kellogg
)
[29.19] What is the type of an enumeration such as
enum Color
? Is it of type
int
?
(added the caveat about converting only valid integers to enumerations thanks to
Mike Radford
)
[33.2] How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc?
(added caveat about using
extern "C"
non-member function thanks to
Rolf Magnus
)
[33.4] Why am I having trouble taking the address of a C++ function?
(rewrote the opening paragraph to give a better explanation of the "short answer")
[35.13] How can I avoid linker errors with my template functions?
Updated!
(added a note about the
export
keyword thanks to
Greg Comeau
)
[35.15] How can I avoid linker errors with my template classes?
Updated!
(added a note about the
export
keyword thanks to
Greg Comeau
)
[35.16] Why do I get linker errors when I use template friends?
(added the required
<>
within the
friend
declaration thanks to
Christophe Barbe
; added the "define it within the class body" approach thanks to
Frode Angell-Petersen AKA Sprudling
)
[36.10] How do I serialize objects that contain pointers to other objects, but those pointers form a tree with no cycles and only "trivial" joins?
(fixed some spelling errors thanks to
Steve Fallows
)
[38.13] Is it possible to convert C++ to C?
(added
LLVM
thanks to
Chris Sabre
)
[39.4] What should be done with macros that contain
if
?
(modified the primary solution to include
(void)0
, and thanks to
Erik Haugen
and
Mike Morearty
, added some pros/cons commentary to the secondary solution; plus did some general wordsmithing)
[39.5] What should be done with macros that have multiple lines?
(modified the primary solution to include
(void)0
, and thanks to
Erik Haugen
and
Mike Morearty
, added some pros/cons commentary to the secondary solution; plus did some general wordsmithing)
[39.7] Why can't the compiler find my header file in
#include "c:\test.h"
?
(softened the wording to reflect the difference between header-names and string-literals thanks to
Michiel Salters
)