4
std::vector<int> interpret(const std::string &src, const std::vector<int> &input = {});

I understand everything about the signature except setting the reference input to {}. What does that mean?

Tony Delroy
  • 102,968
  • 15
  • 177
  • 252
user3577756
  • 643
  • 1
  • 9
  • 13
  • 1
    See also [What are the differences between c-like, constructor, and uniform initialization?](http://stackoverflow.com/questions/24953658/what-are-the-differences-between-c-like-constructor-and-uniform-initialization). – Cornstalks Nov 30 '15 at 02:04
  • In general, `{}` is a "good default" for the type. It's 0 for `int`, `double`, `char`, pointers, etc, applied to each element in the case of arrays, applied to each member in the case of C structures, and typically the user-chosen default for other classes (e.g., an empty string or vector). – chris Nov 30 '15 at 02:22

1 Answers1

7

The = introduces a default value for the parameter... {} in this case indicates an empty vector. Consequently, you can invoke the function with one argument, and input will be empty.

Tony Delroy
  • 102,968
  • 15
  • 177
  • 252