我在 Xcode 命令行应用程序中有以下代码:
#import <Foundation/Foundation.h>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
vector<string> *pv = new vector<string>;
vector<string> &v = *pv;
v.push_back("juy");
v.push_back("zxc");
cout << v[0] << endl << v[1] << endl;
delete pv;
cout << v[0] << endl << v[1] << endl;
cout << pv->operator[](0) << endl << pv->operator[](1) << endl;
return 0;
}
当我运行它时,这是输出:
juy zxc juy zxc juy zxc
问题是:operatordelete
在objective-c++ 中工作吗?它会导致内存泄漏吗?
没有错误,没有异常,也没有警告!