How to set bool pointer to true in struct literal?

前端 未结 3 536

I have the function below which accepts a bool pointer. I\'m wondering if there is any notation which allows me to set the value of the is field to true

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-06 23:48

    No.

    There is no syntax to define a pointer to a primitive type, other than the zero value returned by new. The same goes for numeric types, and strings.

    You either need to create a value before hand to take the address of, or you create the pointer with a zero value, and assign a new value after the fact.

提交回复
热议问题