Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) argument

 

 

An argument is a value that a function or member function needs to perform its task. In a function declaration arguments are seperated by comma's.

 

 

 

 

 

Examples

 

The function 'SayHello' below does not need an argument: all it does it put the text 'Hello' on screen. It does not need additional information to perform its task.

 

#include <iostream>

void SayHello()
{
  std::cout << "Hello\n";
}

 

The function 'SayHelloManyTimes' below needs one argument: how often to put the text 'Hello' on screen. The part 'const int n' is said to be the first and only argument.

 

#include <iostream>

void SayHelloManyTimes(const int n)
{
  for (int i=0; i!=n; ++i)
  {
    std::cout << "Hello\n";
  }
}

 

 

 

 

 

References

 

  1. Working Draft, Standard for Programming Language C++. International Standard. ISO/IEC document number N3936. 2014-08-22. Paragraph 1.3.1
  2. Working Draft, Standard for Programming Language C++. International Standard. ISO/IEC document number N3936. 2014-08-22. Paragraph 1.3.2
  3. Working Draft, Standard for Programming Language C++. International Standard. ISO/IEC document number N3936. 2014-08-22. Paragraph 1.3.3
  4. Working Draft, Standard for Programming Language C++. International Standard. ISO/IEC document number N3936. 2014-08-22. Paragraph 1.3.4

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict