how to declare function with multiple parameter c 2b 2b

Solutions on MaxInterview for how to declare function with multiple parameter c 2b 2b by the best coders in the world

showing results for - "how to declare function with multiple parameter c 2b 2b"
Gail
12 Mar 2020
1// overloaded function
2#include <iostream>
3using namespace std;
4
5int operate (int a, int b)
6{
7  return (a*b);
8}
9
10float operate (float a, float b)
11{
12  return (a/b);
13}
14
15int main ()
16{
17  int x=5,y=2;
18  float n=5.0,m=2.0;
19  cout << operate (x,y);
20  cout << "\n";
21  cout << operate (n,m);
22  cout << "\n";
23  return 0;
24}
25/*
26//Using template->
27#include <iostream>
28
29using namespace std;
30
31template<typename Yourname> //U can write class instead of typename
32
33void print (Yourname value)
34{
35    cout<<value;
36
37
38}
39
40int main()
41{
42print<int>(2);	//you can also use-> print(2);
43cout<<endl;
44print("ali");
45}
46*/