cout<<"int arr = "< cout<<"double arr = "< return 0; } Overload
Method template
Vertor using example
Class template
//this is class template example #include using namespace std; template class mypair { A a, b; public: mypair (A first, A second) { a=first; b=second; } A getmax () { return a>b? a : b; }; }; int main () { mypair myobject (100, 75); mypair myobject2 (100.10, 75.2); mypair myobject3 ("abc", "abcd"); cout << myobject.getmax()< cout << myobject2.getmax()< cout << myobject3.getmax()< return 0; }
Do'stlaringiz bilan baham: |