0

I have started to learn c++ and reading thinking in c++ volume 1. I come across a statement that in c++ one can define a function with unnamed argument list. I could not appreciate the significance of it. Please guide.

int function(int) {
// definition
}

...
function(1); // function call

Thanks in advance.

Galik
  • 47,303
  • 4
  • 80
  • 117
Monk
  • 756
  • 5
  • 16
  • It just means that parameter isn't used in the body of the function. – John Ilacqua Nov 15 '18 at 03:47
  • In that case why can't it be a void. i.e. int function(void) – Monk Nov 15 '18 at 03:53
  • 1
    Or just `int function()`. There are two main reasons that I know of: it's a virtual function where this specific implementation doesn't use that parameter, but others do; or it's used for overload resolution (`operator++` is a specific example). – John Ilacqua Nov 15 '18 at 04:04

0 Answers0