C
Christopher Benson-Manica
#include <map>
#include <vector>
#include <iostream>
using namespace std;
class test
{
public:
unsigned int data;
vector<unsigned int> *v;
test() {data=0; v=new vector<unsigned int>();}
~test() {delete v;}
};
int main(void)
{
map< unsigned int, test > m;
cout << "I hate my implementation!\n";
m[0].data=3;
m[1].data=4;
cout << m[0].data << endl;
return 0;
}
This code hangs after printing the first line when compiled with
Borland 4. It works like a charm when compiled with g++ 3.3.1. Am I
doing something wrong here that invokes undefined behavior, or is
Borland 4 displaying its utter crappiness yet again? If it's the
implementation, can any one suggest a way to work around this?
#include <vector>
#include <iostream>
using namespace std;
class test
{
public:
unsigned int data;
vector<unsigned int> *v;
test() {data=0; v=new vector<unsigned int>();}
~test() {delete v;}
};
int main(void)
{
map< unsigned int, test > m;
cout << "I hate my implementation!\n";
m[0].data=3;
m[1].data=4;
cout << m[0].data << endl;
return 0;
}
This code hangs after printing the first line when compiled with
Borland 4. It works like a charm when compiled with g++ 3.3.1. Am I
doing something wrong here that invokes undefined behavior, or is
Borland 4 displaying its utter crappiness yet again? If it's the
implementation, can any one suggest a way to work around this?