C++ references

Assigning reference return value to a variable When assigning a reference return value to a variable, a copy is made. Here is an example: class References { private: std::string name; public: References(const std::string& name) : name(name) { }; virtual ~References() { }; const std::string& getName() const { return name; }; }; References r(“foo”); std::string n […]

Writing a marker interface in C++

Just figured this out and it caused me about 3 hours of pain, so I figured I’d post it in case I need to do it again. class Base { public: virtual ~Base() {}; }; class Derived : public Base { private: set someSet; public: virtual ~Derived() {}; set getSomeSet() { return someSet; }; }; […]