const char* s1 = "John";
const char* s2 = new char[] {"Cena"};
// is s1 on stack?
// is s2 on heap?
...
// use s1 and s2
...
delete s1;
// do I need to delete s1?
delete[] s2?
// s2 definitely must be deleted right?
我在上面的评论中添加了我的问题。提前致谢。
const char* s1 = "John";
const char* s2 = new char[] {"Cena"};
// is s1 on stack?
// is s2 on heap?
...
// use s1 and s2
...
delete s1;
// do I need to delete s1?
delete[] s2?
// s2 definitely must be deleted right?
我在上面的评论中添加了我的问题。提前致谢。