how to initialize string pointer?

后端 未结 4 1564
再見小時候
再見小時候 2021-01-13 02:58

I want to store the static value in string pointer is it posible?

If I do like

string *array = {\"value\"};

the error occurs

4条回答
  •  醉酒成梦
    2021-01-13 03:08

    As array is an array of strings you could try this:

    int main()
    {
      string *array = new string[1]; 
      array[1] = "value";
      return 0;
    }
    

提交回复
热议问题