Deleting string object in C++

前端 未结 4 1298
挽巷
挽巷 2021-01-18 00:19

I have a string object in my C++ program declared as follows:

string str;

I have copied some data into it and done some operations. Now I w

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 00:58

    Add an Additional scope

    {
      String str;
      ...
      ...
    }
    

    to ensure that str goes out of scope when you no longer need it. Remeber it could be tricky in terms of how other variables are also defined.

提交回复
热议问题