Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
NumType
//Title of this code #include <iostream> using namespace std; template<class T> class Num { T n; public: Num(const T& a){ n = a; } Num(const Num& m){ n = m.n; } virtual ~Num(){} const T& get() const { return this->n; } Num& add(const Num&); }; template<class T> Num<T>& Num<T>::add(const Num<T>& m) { this->n += m.n; return *this; } template<class T> Num<T>& operator+=(Num<T>& a, const Num<T>& b) { return a.add(b); } template<class T> Num<T> operator+(const Num<T>& a, const Num<T>& b) { Num<T> c = a; return operator+=(c, b); } template<class T> ostream& operator<<(ostream& out, const Num<T>& a) { out << a.get(); return out; } #define TYPE int int main() { Num<TYPE> a(1), b(2), c(3); const Num<TYPE> d(4); a += b+d+c+a+c; cout << b+d+a+c; }
run
|
edit
|
history
|
help
0
tes
Find the max and min number in array
pyramid
member initial list
Test 4(2017)
Boggle Game
wealth of banks
merge without extra space Gap method ALgorithm
RecursiveFact
OneANOVA