Code:#include <iostream> using std::cout; using std::endl; int type; template<class T> class templatetask { public: inline T addnumbers (T x1, T y1) { m_x = x1; m_y = y1; return (m_x+m_y); } private: T m_x; T m_y; }; int main () { if (type == 1) { templatetask<int> x; } else { templatetask<double> x; } //to do stuff ...the problem is that, outside of if statement, "x" can't get accessed to. any simple way //to enhance this code to be able t access x this way?. return 0; }


Reply With Quote
