#include <iostream>
class printData
{
public:
void print(int i) {
cout << "Printing int: " << i << endl;
}
void print(double f) {
cout << "Printing float: " << f << endl;
}
void print(char* c) {
cout << "Printing character: " << c << endl;
}
};
void main(void)
{
printData pd;
// Call print to print integer
pd.print(9);
// Call print to print float
pd.print(100.200);
// Call print to print character
pd.print("Hello C++");
getch();
}
Output:
Printing int: 9
Printing float: 100.200
Printing character: Hello C++
Ask Question