When I debug this in MS VS 2005 in class Has, List lis pointers(front and back) are initialized to 0 but each list in the has[10000] array pointers are not initialized. I cannot figure why this is happening. Any pointers? (pun intended).
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;
class Node{
public:
string value;
Node *next;
Node():value(""), next(NULL){}
};
class List{
public:
Node *front;
Node *back;
List() {front = new Node(), back = new Node();}
};
class HNode{
public:
List l;
HNode():l(){}/*not sure if this constructor is right for the list in this node*/
///the line above was HashNode, changed to Hnode///
};
class Hash{
public:
List lis;
HNode *has[10000];
Hash(){has[10000];}
void addone(string s){
has[100]->l.enqueue(s);
}
};
int main(){
Hash hashdic;
string add="successfully";
hashdic.addone(add);
return 0;
}
Spark notes: When the code is ran there is a Hash dic with a list lis with pointers initialized to 0xccccccc. Each instance in the has[10000] array has a list with pointers initialized to "???" Help please.
Edited by c++leaner123, 11 March 2009 - 08:44 PM.
changed constructor


Sign In
Create Account

Back to top









