[Dev-C++] Need help with vector<...>
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <qa...@ho...> - 2002-10-15 23:01:58
|
Hi again.
If I place the following line in the header file "ComputerPlayer.h" as a=
private member of my class "ComputerPlayer"
vector< pair< unsigned long long, pair< vector< pair<int, double> >,=
vector< pair<int, double> > > > > legalVect;
the program compiles and links just fine, but it's terminated almost=
immediately when run.
I'm going to use the vector in two different functions, thats why I need it=
as a member of the class.
For debugging purposes, I implemented it as a local member in one of the=
functions (At the moment the only one of the two implemented), see below.=
Now it works just great. Why is that? Why can't I have it in the=
headerfile?
//--------------------------------------------------------------------------=
-------------------------------------
void ComputerPlayer::insertSortedLegalMoves(vector< pair<int, double> >=
sortedLegalMoves,
unsigned long long legalMoves,
bool blackToMove){
//This is not printed when vector<...> is declared in the header
cout << "Debug... Function 'insertSortedLegalMoves(...)' entered" << endl;
// If I uncomment the line below and comment out the one in the header the=
program runs fine. WHY????
//vector< pair< unsigned long long, pair< vector< pair<int, double> >,=
vector< pair<int, double> > > > > legalVect;
vector< pair< unsigned long long, pair< vector< pair<int, double> >,=
vector< pair<int, double> > > > >::iterator iter;
for(iter =3D legalVect.begin(); iter < legalVect.end(); iter++){
if(iter->first =3D=3D legalMoves){
if(blackToMove){
iter->second.first =3D sortedLegalMoves;
return;
}
iter->second.second =3D sortedLegalMoves;
return;
}
}
// If legalMoves not found in the vector this code is executed
vector< pair<int, double> > dummyVec;
pair< vector< pair<int, double> >, vector< pair<int, double> > > tmp;
if(blackToMove)
tmp =3D pair< vector< pair<int, double> >, vector< pair<int, double> >=
>(sortedLegalMoves, dummyVec);
else
tmp =3D pair< vector< pair<int, double> >, vector< pair<int, double> >=
>(dummyVec, sortedLegalMoves);
legalVect.push_back(pair<unsigned long long, pair< vector< pair<int,=
double> >, vector< pair<int, double> > > >(legalMoves, tmp));
}
//--------------------------------------------------------------------------=
-------------------------------------
Any help is appreciated. Thanx
/J=F6rgenk
|