C++ Tips: Miscellaneous


Table of Contents


Uncategorized

Why use C++?
Pointer offsetting
Local constants in classes
Name scoping
The orthodox canonical class form
Hiding information in classes
The maximal munch rule
Method name scoping example
Function declarations with no definitions
Sizeof and string literals
The type of string literals is not const correct
No way to express "use-default" for method calls
Types, variables, and name spaces
Compilers and register variables
Where to put default argument values
Var args and base classes
Handling variable argument lists
Using setjmp/longjmp with C++
Never redefine an inherited nonvirtual function
Visibility of nested classes
Continuation of comments
Calling static class members via pointers
Pass by value versus pass via const reference
Ambiguous conversions
A hack for detecting stack vs heap allocated addresses
Determining if an object is on the heap (again)
Built in types as classes
Semantic checking of "dead" code
Creating a derived class creates a new scope level
Put "Class::" immediately before identifier being scoped
Argument matching is implementation-dependent
Catching (typo) errors in == expressions
Suppressing literal conversions to double
Various views on abstract data types
An amusing instantiation of an abstract class
Printing ascii-binary output
Modifying an object twice in the same expression
Declared scope begins inside declaration
Terminology for ADT, abstract class, etc
Comparing against "this"
A non-portable way to detect redirection of stdio
Introduction to concurrency
Scope of variables declared in for() while() if()
Question about "intelligent" use of ?: construct
Why not mix-n-match object files from different compilers?
Leading underscores in macro names
Method access and visibility
Notes on the ARM and D&E
Simulating "named parameters"
Casts, lvalues, and assignment
Order of evaluation or is it grouping?
A first or last authority on C++ - the compiler
Type tags, scope, and forward declarations
Per-class or per-object encapsulation?
New keyword "explicit"
Definition of function scope
Parenthesis and declarations
rules of thumb for reading declarations
Unspecified versus undefined behavior
A generalized indicator of failure, or NULL is nothing
fallible
ANSI and ISO standards
Lvalues and rvalues
Thoughts on adding public member functions
set_new_handler
creating objects on the stack or the heap
Myth - C++ is a superset of ANSI C
incrementing enums
Is protected data a bad idea?
Another difference between C and C++
Declaration or expression - that is the question
what use are elaborated type names?
Terminology - function prototype, type, and signature
another way to swap bytes
Duff's device
more on undefined behavior
does C++ - C amount to 0
public base class method to private derived = nonsense
breaks in loops and structured programming
continuation and comments
Thoughts on ISO C++
why change the scope of loop variables
using const versus define
volatile keyword
explicit keyword background
forward declarations and namespaces
sizeof in an #if directive
basic explanation of temporaries and return-by-value
function versus variable declarations
draft standard schedule
why C++
declaration versus expression
comparing address
exposing privates
backdoor use of memcpy
using leading _ or __ for identifiers
a tip for multidimensional diehards
deleting and casting of an incomplete type
Java and C++. A Critical Comparison
extending enums
scoping and nested for loops
what is conservative garbage collection
implicit and explicit conversions
const vs define and compiler optimization
the meaning of const volatile
forward reference to nested class
next public C++ draft working paper
ruminations on c++
l/rvalues in C and C++
order of evaluation
stepping through enum values
what is const &X
changing an object's type
signedness of char
abstractions and data conversion
portability and "test and set"
detecting endianism
Guru #4 - class mechanics - author's answer
pointer to member function syntax
multiple addresses for a single instance
control flow analysis problem
pointer type and access specifiers
choosing identifier names
identifier name collisions with standard functions...
reference to derived is not to a base
restrict keyword coming
the scope of function and class names
a sharp angle on function pointers
one definition rule diagnosing
alternative default arguments?
access protection, inheritance, and base class pointers
forwarding function efficiency
simple string conversions using streams
designing a case insensitive string class
terminology - intrusive containers
The One-Definition Rule
C++ coding standards
dealing with collections of heterogeneous objects
terminology - static and dynamic
the static keyword
specific bit sized datatypes
is it worth testing "this" for NULL
changing the precendence of user defined operators
ISO C++ ratified
forward declaration of nested class?
reference counting (part I)
C++ Standard over the web
one definition rule and multiple includes
a glossary of OO terminologies
multithreaded reference counting concerns
C++ porting guidelines
registering functions with atexit
History and C++ compatibility with C9X
precedence and order of operations
conditionals and precedence
pre- vs post-increment
the "overhead" of C++
enforcing some constraints at compile-time
accessing prot/private members via base class ptr/ref
Equivalent Code?
the legality of null statements
recursively defined function pointers
nested/local functions/classes
signed versus unsigned characters
practical concerns of signed versus unsigned characters
constant declarations in include files
internationalization concerns with uppercasing strings
abstract data type versus abstract base class
c++ compiler conformance
nonequivalence of int and int-like types
enforcing checking for error return values
c++ interview question with "no loop" solution
Enforcing Rules For Derived Classes
compile-time inheritance checking
Style Case Study #1: Index Tables
function objects
uses and abuses of access rights

Alignment

Dealing with word alignment issues
the strictest data alignment requirements
alignment requirements of classes
portably determining alignment
still more on portability and alignment
alignment of character array

bool

Another reason NOT to define a boolean enum
Booleans, the final edition
why bool - a rationale

auto_ptr

What is auto_ptr?
example usage of auto_ptr<>
musings on auto_ptr
what is auto_ptr<>
newly refined auto_ptr
exceptions, auto pointers, and class design
auto_ptr? use with caution!
using auto_ptr
smart pointer miscellanea
what is auto_ptr_ref for?
using auto_ptr in containers

Goto

do-while as an implicit goto
no go (to)
a concise example using "goto"

Main

Correct prototype for main()
returning from main
treating "main" specially

Naming Conventions

variables and underscores
simple, "intuitive" member variable naming
simple naming conventions
a practical naming convention

Pointers

pointer comparisons
pointer nuts and bolts
pointer tinkering
conversions of pointer-to-pointers
on the sizes of pointers

Return

Polymorphic return types
Covariance of return types
Accessibility of private return types
returning self reference from mutators
overloading complexity and return types
return and void
covariant return types

Null and Zero

Just when you thought it was safe to use NULL
Detecting null references
Portability and comparing null pointers
A perspective on NULL
Casting of 0 in variadic functions
Is 0 a null pointer or integer
a potpourri of NULL
definition of NULL
a template definition for NULL

Inlining Concerns

Address of inline functions and methods
the relationship between static and inline
non-member inline functions with external linkage
extern and inline - orthogonal concepts
linkage of inline functions
extern inlines by default
virtuals and inlining
inlining of variadic functions
inlining miscellanea
when is inline reasonable
when is inline reasonable (part ii)

Typedefs

What is the relationship between typedef and struct/class?
Using a typedef for superclass
nonequivalence of typedefs and macros
partial template specialization and traits
typedefs as tags and class labels
the utility of typedef
typedef and language linkages
typedefs and const
typedefs versus defines
how to use "inherited" typedefs
example of traits usage
inheritance and traits

Unions

Unions and objects
Anonymous structs and unions
Scoping and anonymous unions
static members in unions
anonymous unions

Name Hiding

Name hiding or everything I didn't want to know about scopes
scopes and name hiding
How to easily avoid hiding of inherited virtual functions
name hiding fundamentals

Virtualness

private virtual functions
What conditions for virtual dispatch?
how to (inadvertently) call a pure virtual function
implementations for pure virtual functions
Making all methods virtual
Pure virtual methods may have implementations
Possible to call undefined pure virtual functions
Private virtual methods
Use virtual keyword explicitly in derived classes
Calling pure virtual methods
do private virtuals make sense
overriding virtual functions
calling a pure virtual
automatic conversions - just say no
error handling schemes
does private virtual make sense?
defining pure virtuals
the cost of virtual functions

Struct and Class

what is a POD
bjarne on struct versus class
aggregates, PODs, and constructors
"plain old data"

Globals

Globals and static variables
Are global variables evil?
stripping unused globals

Sequence Points

Sequence points and expression side effects
Overloading eliminates sequence points
Inlining, order of evaluation, and sequence points
Sequence points and order-of-evaluation
sequence points in C and C++
sequence points and chained assignment
sequence points and built-in operators

Numerical Concerns

Float versus double
Floating point equality
a double equivalent to atoi()
converting doubles to strings with precision
64 bit integers
using numeric_limits
floating point values as compile time constants
remainder example using numeric_limits
double or nothing (float vs double)

Friendship

"Friends? Just say 'no!'"
Nested classes, friends, and statics
Can friends be "good"?
Beating friends into the ground
Friends and nested classes and enums
what are friends for
friendship and encapsulation
selective friendship
justification for friends
controlling access without outright friendship
forward declaring friends
hate friends/love friends

Initialization

insisting on initialized data member declarations
switch statements and variable initialization
zero initialization of built-in types
deferred initialization of globals
Initializing constant integral data members
Initialization of automatic aggregates
idiom for order of initializing data members
default and no initialization
why initialize static data outside class declaration

References

A reference member in a class will prohibit assignment
array of references disallowed
References, const pointers, and storage
References, const pointers, and storage (more)
reference to a void
arrays and references
how efficient are references vs pointers
what exactly are references
sizeof, parenthesis, and references
implementation notes on references

Typename

details on using typename
simple explaination of typename
typename keyword for return values

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.