Default values for array arguments

前端 未结 6 796
孤独总比滥情好
孤独总比滥情好 2021-01-04 06:53

Just playing around a little with C++. What I really want to do is to be able to setup a function with default values defined for an array or pointer argument. To keep thing

6条回答
  •  攒了一身酷
    2021-01-04 07:43

    A default parameter must be valid.

    You can call

    f("abc")

    but never

    f({'a','b','c'});

    "abc" is effectively an address in memory and {'a','b','c'} means initialise an array or struct/class.

提交回复
热议问题