perayo
04-27-2004, 05:42 PM
void somefunction(map<char,vector<node*> >&);
void subfunction(map<char,vector<node*> >&, queue<int>&);
void main(){
map<char,vector<node*> > m1;
somefunction(m1);
}
void somefunction(map<char,vector<node*> >& m){
queue<int> Q;
subfunction(m,Q);
}
void subfunction(map<char,vector<node*> >& m, queue<int>& q){
//I = m.begin();
node *ptr = I->second[q.front()];
cout << ptr->data << endl;
}
The error is in the subfunction. Assuming the map is
initialized with data, the "ptr->data" does not work. When I
debug, it says ptr is a "Bad Ptr". Does this have anything to
do with calling by reference within a function? It works fine when I replace "q.front()" with an integer. Thanks.
void subfunction(map<char,vector<node*> >&, queue<int>&);
void main(){
map<char,vector<node*> > m1;
somefunction(m1);
}
void somefunction(map<char,vector<node*> >& m){
queue<int> Q;
subfunction(m,Q);
}
void subfunction(map<char,vector<node*> >& m, queue<int>& q){
//I = m.begin();
node *ptr = I->second[q.front()];
cout << ptr->data << endl;
}
The error is in the subfunction. Assuming the map is
initialized with data, the "ptr->data" does not work. When I
debug, it says ptr is a "Bad Ptr". Does this have anything to
do with calling by reference within a function? It works fine when I replace "q.front()" with an integer. Thanks.