I'm having problems with the scope of some functions. I'm creating a dictionary class that uses an enty class to store the entries. Now I have this function that generates a and index containing a keyword and all the pages that contain the keyword.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
void generateDictionnary(char L[MAX_NB_LINK][MAX_SIZE_URL], char *words, char *urls){
char URL[MAX_SIZE_URL];
//1)Rempli Index[] avec les mots
ifstream file;
file.open(words);
while(!file.eof()){
file.getline(URL, MAX_SIZE_URL);
if(!estPresent(URL))
inserer(URL);
}
//Cherche Pour le mots dans Index[i] tout les pages webs qui contient ce MC
for(int mot = 0; mot < indiceCourant; mot++){
//Ouvre le fichier qui se situe a la Ieme ligne de L pour le mot X
for(int ligne = 0; ligne < nmbr_liens; ligne++){
ifstream file2;
file2.open(L[ligne]);
bool contient = false;
//Ouvjre la Jeme ligne de la page I
for(int line_file = 0; !file.eof() and !contient; line_file++){
file2.getline(URL, MAX_SIZE_URL);
if(contienMot(Index[mot]->name, URL)){
inserer(mot, ligne);
contient = true;
}
}
}
}
}
| |
It calls some other functions (all of them are members of the class Dictionnaire) and mainly messes around with the **Index and indiceCourant (current Index) which are the private members of a Dictionnaire. Here are the errors I'm getting:
ALL.cpp: In function ‘void generateDictionnary(char (*)[300], char*, char*)’:
ALL.cpp:124: error: ‘estPresent’ was not declared in this scope
ALL.cpp:125: error: ‘inserer’ was not declared in this scope
ALL.cpp:128: error: ‘indiceCourant’ was not declared in this scope
ALL.cpp:137: error: ‘Index’ was not declared in this scope
ALL.cpp:137: error: ‘contienMot’ was not declared in this scope
ALL.cpp:138: error: ‘inserer’ was not declared in this scope
All of the mentioned functions are declared and defined above so I don't understand the scoping problem.
I'm also having problems with some global constants. I want to put the Dictionnaire class in a separate .cpp. The problem is that it uses some global constants and arrays which are found in the main. If someone could explain to me how to include them for the Dictionnaire.cpp.