Default values for array arguments

前端 未结 6 857
孤独总比滥情好
孤独总比滥情好 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:25

    "abc" is an expression. It happens to behave specially, different from all other expressions, when it is used to initialize a variable of type array of char.

    {'a','b','c'} is not an expression but an initializer. It is only syntactically allowed in variable definitions. There, the syntax allows either an expression or a non-expression initializer, but that does not man that initializers can be used as expressions anywhere else.

提交回复
热议问题