A function with no arguments in the prototype
Consider we have a function with the following prototype
void fun();
How many arguments it will take in C and C++?
Ans:In C it can take any no of arguments, but in C++ it takes no argument.
Ex:
int main()
{
int i,j,k;
i = 1;
j = 2;
k = 3;
foo(); //valid in both C and C++
foo(i); //Valid in C but invalid in C++
foo(i ,j); //Valid in C but invalid in C++
foo(i,j,k); //Valid in C but invalid in C++
}
void foo()
{
cout<<"In function";
}
Thursday, December 4, 2008
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment