So I understand how templates work, but I don't understand how to use them in a main (or at least the syntax I need to use them).
All I want to do is declare it, increment it, and print it.Code:#include <cstdlib> #include <iostream> using std::cout; using std::endl; template<class TYPE> class pair { public: pair(TYPE x): c1(x),c2(x + 1) {} void increment() {c1++; c2++;} void print() const {cout << c1 << "\t" << c2;} private: TYPE c1, c2; }; int main() { int x = 5; pair<int>pair(x); x.pair<int>increment(); x.pair<int>print(); system("PAUSE"); }



LinkBack URL
About LinkBacks


