Hi!
I have run into a problem that I can't solve on my own. I'm pretty new in C++ programming so I really don't know what has to be defined and what does the compiler define if I leave out. My problem could probably arrise from I'm not having copy constructors defined.
But first I should probably say that I'm using Visual C++ 6.0
In my implementation, I have a "vector<TestCase> testCaseList" where TestCase is defined as following:
#include <string>
#include <map>
#include <vector>
#ifdef _WIN32
using namespace std;
#endif
class TestCase
{
public:
TestCase();
virtual ~TestCase();
map<string, string, std::less<string> > testCaseInfo;
map<int, map<string, string, std::less<string> >, std::less<int> > actionList;
map<int,int, std::less<int> > actionOrder;
map<string, string, std::less<string> > actionParameterList;
vector<string> expectedValueList;
};
When I try to insert a new TestCase into my vector I get an "Unhandled exception ... access violation" error. This is the code which I use to insert the new object in the vector:
testCaseList.push_back(TestCase());
I've tried to debug it in VC++ and as far as I can see the problem arise after the TestCase-constructor has executed and the program is in the push_back() function.
I've read that some one else had a similar problem but his vector contained a class which only had strings as members so someone said that in that case no special copy-constructor was needed. But in my case, when TestCase has maps and vectors as members, do I need to define a copy constructor for my TestCase-class, and in that case how do I do that and can anyone please instruct me what it should do?
thankful every tip I can get for finding a solution
I have run into a problem that I can't solve on my own. I'm pretty new in C++ programming so I really don't know what has to be defined and what does the compiler define if I leave out. My problem could probably arrise from I'm not having copy constructors defined.
But first I should probably say that I'm using Visual C++ 6.0
In my implementation, I have a "vector<TestCase> testCaseList" where TestCase is defined as following:
#include <string>
#include <map>
#include <vector>
#ifdef _WIN32
using namespace std;
#endif
class TestCase
{
public:
TestCase();
virtual ~TestCase();
map<string, string, std::less<string> > testCaseInfo;
map<int, map<string, string, std::less<string> >, std::less<int> > actionList;
map<int,int, std::less<int> > actionOrder;
map<string, string, std::less<string> > actionParameterList;
vector<string> expectedValueList;
};
When I try to insert a new TestCase into my vector I get an "Unhandled exception ... access violation" error. This is the code which I use to insert the new object in the vector:
testCaseList.push_back(TestCase());
I've tried to debug it in VC++ and as far as I can see the problem arise after the TestCase-constructor has executed and the program is in the push_back() function.
I've read that some one else had a similar problem but his vector contained a class which only had strings as members so someone said that in that case no special copy-constructor was needed. But in my case, when TestCase has maps and vectors as members, do I need to define a copy constructor for my TestCase-class, and in that case how do I do that and can anyone please instruct me what it should do?
thankful every tip I can get for finding a solution