Assigning parameter value in function declaration?
问题 I don't understand why in this constructor declaration, the input parameter is assigned 2. What does it mean? Does it mean that by default (unless something else is passed), size will be 2? Graph(int size = 2); I've never seen syntax like this, so I don't even know how to Google it :/ Thanks in advance! 回答1: You're right, the parameter value will be 2 by default. So you can call it normally: Graph g(5); in which case size will be equal to 5, or you can call it without providing a value: Graph