Tutorial by Examples

C++11 C++11 introduces two new special member functions: the move constructor and the move assignment operator. For all the same reasons that you want to follow the Rule of Three in C++03, you usually want to follow the Rule of Five in C++11: If a class requires ONE of five special member functions...
C++11 We can combine the principles of the Rule of Five and RAII to get a much leaner interface: the Rule of Zero: any resource that needs to be managed should be in its own type. That type would have to follow the Rule of Five, but all users of that resource do not need to write any of the five sp...
c++03 The Rule of Three states that if a type ever needs to have a user-defined copy constructor, copy assignment operator, or destructor, then it must have all three. The reason for the rule is that a class which needs any of the three manages some resource (file handles, dynamically allocated me...
When writing a copy assignment operator, it is very important that it be able to work in the event of self-assignment. That is, it has to allow this: SomeType t = ...; t = t; Self-assignment usually doesn't happen in such an obvious way. It typically happens via a circuitous route through vario...

Page 1 of 1