I have just started learning c++ and i came across this concept of function declaration. It says "a function must be declared before use" but i have written a program where i have commented the function declaration and used the function. My program is still working. I want to know what i am missing here. I am running this program on eclipse. It is a simple program where i am passing reference of a and b to swap function and swapping values of a and b.
#include <iostream>
#include <stdio.h>
#pragma pack(1)
using namespace std;
//void swap(int &,int &);
int main()
{
int num1,num2;
cout<<endl<<"Enter two nos\n";
cin>>num1>>num2;
cout<<"\nBefore call\t"<<num1<<"\t"<<num2<<endl;
swap(num1,num2);
cout<<"\nAfter call\t"<<num1<<"\t"<<num2<<endl;
}
void swap(int &a,int &b) //Saving memory here
{
int c=a;
a=b;
b=c;
}