/// ###### MAIN.CXX ###### #include "poop.h" #include int main(int argc, char **argv) { using namespace Water; Poop firstPoop; Poop secondPoop; firstPoop.setPoopValue(10); secondPoop.setPoopValue(20); Poop poop = firstPoop + secondPoop; printf("I've just pooped %d times\n", poop.poopValue()); return 0; } /// ###### POOP.H ###### #ifndef CLS_H #define CLS_H namespace Water { class Poop { public: friend Poop operator+(const Poop &, const Poop &); Poop(); ~Poop(); int poopValue() const; void setPoopValue(const int v); private: int m_poopVariable; }; Poop operator+(const Poop &first, const Poop &second); }; #endif // CLS_H /// ###### POOP.CXX ###### #include "poop.h" #include Water::Poop::Poop() : m_poopVariable(0) { } Water::Poop::~Poop() { printf("Poop sinks with score %d\n", m_poopVariable); } void Water::Poop::setPoopValue(const int v) { m_poopVariable = v; } int Water::Poop::poopValue() const { return m_poopVariable; } Water::Poop Water::operator+(const Poop &first, const Poop &second) { Poop third; third.m_poopVariable = first.m_poopVariable + second.m_poopVariable; return third; }