Global Vector of objects

Hi, I am trying to create a class to hold a global vector variable that I can share between three application forms.
The files compiles ok, yet when I run it, it crashes on vector.
"Check to determine if the object is null before calling the method.
Use the 'new' keyword to create an object instance."

my class like this

//VectorTracks.h
#pragma once
#ifndef VECTORTRACKS_H
#define VECTORTRACKS_H
//#include <string>
#include <vector>
#include "TrObject.h"
//using namespace std;
namespace Capture
{
public ref class VectorTracks
{
public: VectorTracks();
public: ~VectorTracks();
public: static vector<TrObject>* trkObjects;

};
}
#endif

//VectorTracks.cpp
#include "stdafx.h"
#include "VectorTracks.h"

namespace Capture
{
VectorTracks::VectorTracks(){
trkObjects = new vector<TrObject>();
}

VectorTracks::~VectorTracks(){
delete trkObjects;
}
}

I have a feeling that I am deleting the trkObjects early!!
Thanks JLBorges...
Actually what I did,is remove the constructor and destructor, leaving just static vector<TrObject>* trkObjects;
In the main form, call VectorTracks::trkObjects = new vector<TrObject>();
and delete the object when the main form is closed.
Topic archived. No new replies allowed.