After dynamically allocating struct, I thought it woudl be prudent to put 'delete' at the end. But it gave me a runtime error. Compiled ok, though. So if I get rid of 'delete', it runs fine. But I worry there could be a memory leak. What would be the safe way to handle this code?
#include <iostream>
#include <vector>
using namespace std;
typedef struct
{
vector<char*> vstr;
vector<int> vint;
}VecStrInt;
int main()
{
VecStrInt * mtx = new VecStrInt();
mtx[0].vstr.push_back("Hello");
mtx[0].vint.push_back(1);
cout<<mtx[0].vint.at(0)<<endl;
cout<<mtx[0].vstr.at(0)<<endl;
//delete [] mtx;
return 0;
}