954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Function calls in C++

How do I call a function without actually sending any values for its arguments?
For example I have the function

int Test ( int a, int b)
   {
      b= a * a ;
    }


then I call this function from some place in the program,

Test (??,??);

What do I have to do in order to call this function (trigger it) but not actually pass any values for a and b,,?

Thanks

depsch
Newbie Poster
5 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

In C++ functions can have parameters with default values

int Test ( int a = 1, int b = 2)
   {
      return a * b ;
    }


now when the program calls Test with no parameters, the compiler will force them to the values shown above.

int return_value = Test();
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You