Advertisement
Maplewing

9/1 C++: Function Overloading & Reference

Aug 31st, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. void input(int &a){
  6.     scanf("%d", &a);
  7. }
  8.  
  9. void input(double &a){
  10.     scanf("%lf", &a);
  11. }
  12.  
  13.  
  14. void print(int a){
  15.     printf("%d\n", a);
  16. }
  17.  
  18. void print(double a){
  19.     printf("%lf\n", a);
  20. }
  21.  
  22. int main(){
  23.     int a;
  24.     double b;
  25.    
  26.     input(a);
  27.     input(b);
  28.    
  29.     print(a);
  30.     print(b);
  31.    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement