Re: Declaration and definition in C++. Hai,
The above declaration is correct.
If u cant understand,refer this...
Consider a normal C++ program,
class a
{
add();->Function call
}
void a:add()->Function Definition
{
int c1;->declaration of a variable
cout<<"Enter a1";
cin>>a1;
cout<<"Enter b1";
cin>>b1;
c1=a1+b1;->Definition of a variable
cout<<c1;
}
This is incase of C++ Program..
If u use C,then
void main()
{
int c;->Declaration(Since u didnt assigned value)
c=add();->(Here c is defined(i.e..,Value is assigned through function)
printf("%d",c);
}
int add()
{
int a1,b1,c1;
printf("Enter two numbers");
scanf("%d%d",&a1,&b1);
c1=a1+b1;
return(c1);
}
In the above function the value returned by 'add()' is assigned to 'c' |