For the purposes of these examples let's pretend we have the class Cat
:
#include <iostream>
#include <string>
using namespace std;
class Cat {
public:
Cat(string name = "unnamed") {
Member initializer syntax is a great way to give data members initial values on object initialization.
"All other things being equal, your code will run faster if you use initialization lists rather than assignment." - isocpp.org
For the purposes of this example let's pretend we have the class Cat
:
#include <iostream>
#include <string>
using namespace std;
// Example of how to implement a templated linked list | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
class Cat { | |
public: | |
Cat(string name = "unnamed", int age = 0): name(name), age(age) { } | |
const string name; | |
int age; |
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+ |
class Singleton { | |
public: | |
// Lazily get reference to a static instance of Singleton. | |
// The benifit of the following inplementation: | |
// * It lazily creates a Singleton. | |
// * It creates the Singleton on the global stack, so when the program ends | |
// the Singleton is automatically deallocated and it's deconstructor is invoked. | |
static Singleton& getInstance() { | |
// The following line (starting with `static`) only executes once, | |
// no matter how many times this function executes. |