S
shan_rish
I gather from this group's posts that there is no need of function
prototypes if the function is "seen" before it is called. (i.e)the
function should be defined before the main().
But in the following code i defined the function after the main() and
the code still works. Any thoughts. I am using Bloodshed C++ compiler.
#include<iostream>
using namespace std;
int main()
{
int x=10, y=20;
swap(x,y);
cout<<"x = "<<x<<" y = "<<y;
cin>>x;
return 0;
}
void swap(int& i, int& j)
{
int tmp = i;
i = j;
j = tmp;
}
Cheers
Shan
prototypes if the function is "seen" before it is called. (i.e)the
function should be defined before the main().
But in the following code i defined the function after the main() and
the code still works. Any thoughts. I am using Bloodshed C++ compiler.
#include<iostream>
using namespace std;
int main()
{
int x=10, y=20;
swap(x,y);
cout<<"x = "<<x<<" y = "<<y;
cin>>x;
return 0;
}
void swap(int& i, int& j)
{
int tmp = i;
i = j;
j = tmp;
}
Cheers
Shan