7-More Overloading

7-More Overloading - } template < class T...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> using namespace std; //void Abc() { cout << "Hello";} //void Abc(int x) { cout << "World";} //void Abc(int y = 1) { cout << "Goodbye" << y << endl;} // Supports Abc() && Abc(int) //void Abc(float y = 1) { cout << "Good Day" << y << endl;} // Supports Abc() && Abc(float) template < class T > void Abc(T first) { cout << "Template\n";
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } template &lt; class T &gt; void Abc(T first, T second) { cout &lt;&lt; &quot;It takes two\n&quot;; } int main (void) { int number = 0; //Abc(); Abc(6); Abc(4.5f); Abc(4.5); Abc(1, 2); do { cout &lt;&lt; &quot;Give me a number: &quot;; cin &gt;&gt; number; cout &lt;&lt; &quot;Your number is &quot; &lt;&lt; number &lt;&lt; endl; cin.clear(); cin.ignore(); }while (false);//(number == 0); return 0; }...
View Full Document

Ask a homework question - tutors are online