Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 2.01 KB

CppArgument.md

File metadata and controls

50 lines (39 loc) · 2.01 KB
  • argument <function call expression>: expression in the comma-separated list bounded by the parentheses [1]
  • argument <function-like macro> sequence of preprocessing tokens in the comma-separated list bounded by the parentheses [2]
  • argument <throw expression> the operand of throw [3]
  • argument <template instantiation> expression, type-id or template-name in the comma-separated list bounded by the angle brackets [4]

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() noexcept
{
  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";
  }
}
  • [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