Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <class T>
- class Accum
- {
- private:
- T total;
- public:
- Accum(T start) : total(start) {};
- T operator+= (T const &t) { return total +=t;}
- T GetTotal() { return total;}
- };
- int main()
- {
- Accum integers(10);
- integers += 10;
- cout << integers.GetTotal() << endl;
- Accum strings(string(""));
- strings += "Vremena";
- strings += " i nravi";
- cout << strings.GetTotal() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement