tampurus

0 function overloading

Dec 2nd, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void Print() {
  4.     cout<<"nothing to print"<<endl;;
  5. }
  6. void Print(int n){
  7.     cout<<n<<endl;
  8. }
  9. void Print(char c){
  10.     cout<<c<<endl;
  11. }
  12. void Print(double f){
  13.     cout<<f<<endl;
  14. }
  15. int main()
  16. {
  17.     Print();
  18.     Print(5);
  19.     Print('k');
  20.     Print(5.23);
  21.     return 0;
  22. }
  23. /*
  24. Output
  25. nothing to print
  26. 5
  27. k
  28. 5.23
  29. */
Advertisement
Add Comment
Please, Sign In to add comment