-
When does
static
Object Initialization Occur?When working with
static
or global variables in C or C++, we know the compiler allocates storage for them in the application's data segment. However, when the variable is an instance of a C++ class, it must be initialized as well as allocated. While the C++ language specification explains when this initialization takes place, it is a rather simple matter to demonstrate the rules for clarity. -
There's More Than One Way to Skin a Singleton
After working with C++ for a while, we all come across situations where we need to create one and only one instance of a given object type. However, depending on your needs, there's more than one way to go about implementing a singleton.
-
const
-antly ChangingIn addition to the
virtual
andinline
method modifiers, C++ also allows the addition of theconst
modifier on class methods. Theconst
modifier indicates the method does not alter the state of class member variables. -
When
virtual
Functions Won't Fallinline
C++ offers two useful modifiers for class methods:
virtual
andinline
. Avirtual
method can inherit new behavior from derived classes, while theinline
modifier requests that the compiler place the content of the method "inline" wherever the method is invoked rather than having a single instance of the code that is called from multiple places. You can think of it as simply having the compiler expand the content of your method wherever you invoke the method. But how does the compiler handle these modifiers when they are used together? -
More Than Resource Contention
One of the first things we learn about multithreaded programming is the need to guard against simultaneous read-write access to shared resources, but this isn't always a simple matter.
beginner (9)
c plus plus (5)
c sharp (1)
closure (1)
cocoapods (1)
const correctness (1)
deadlocks (1)
delegates (1)
events (2)
forms (1)
inline functions (1)
ios (3)
javascript (11)
jccc (6)
multithreading (2)
mutable (1)
react (1)
react native (1)
security (1)
singletons (1)
ssl (1)
this (1)
virtual functions (1)
web admin (1)