// tempmemb.cpp -- template members #include using std::cout; using std::endl; template class beta { private: template // nested template class member class hold { private: V val; public: hold(V v = 0) : val(v) {} void show() const { cout << val << endl; } V Value() const { return val; } }; hold q; // template object hold n; // template object public: beta( T t, int i) : q(t), n(i) {} template // template method U blab(U u, T t) { return (n.Value() + q.Value()) * u / t; } void Show() const { q.show(); n.show();} }; int main() { beta guy(3.5, 3); cout << "T was set to double\n"; guy.Show(); cout << "V was set to T, which is double, then V was set to int\n"; cout << guy.blab(10, 2.3) << endl; cout << "U was set to int\n"; cout << guy.blab(10.0, 2.3) << endl; cout << "U was set to double\n"; cout << "Done\n"; // std::cin.get(); return 0; }