Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

strange parse-error

I made the following c++ code, and another 200 lines that aren't interesting here. it gives a parse error on line 40 when I compile it with dev-c++, and I can't figure out what's wrong... all the brackets and semi-colons are in the right place, and I copied that block of 4 lines from somewhere else in the program that worked perfectly. can anyone help?

ow, the exact error is "parse error before ';'"

#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;

int aantalwoorden(){
ifstream invoer("woordenboek.txt", ios::in);
char kar;
int woorden = 0;

kar = invoer.get();

while(kar != '\n'){
woorden = woorden*10 + kar - 48;
kar = invoer.get() ;
}
invoer.close();
return woorden;
}

class woord{
public:
string text;
woord *volgende;
};

void nieuwwoord(int & n, woord* ingang){
woord *p = ingang, *hulp;
string woord;
int woordlengte;
cout << "geef het woord dat je aan de lijst wil toevoegen" << endl;
cin >> woord;
woordlengte = woord.size();
if (woordlengte == 5 || woordlengte == 6){
for(int i=0; i<n; i++){
p = p->volgende;
}
hulp = p;
p = new woord; // gives an error here.
p->text = woord;
hulp->volgende = p;
}
}
[1490 byte] By [zoef] at [2007-11-11 11:59:01]
# 1 Re: strange parse-error
don't use a variable name same as the class name ..
"string woord;"

the compiler don't know how to creat for p a new variable of type string ... it's something ambiguous for him i mean ...
Amahdy at 2007-11-11 20:55:32 >
# 2 Re: strange parse-error
that works, thanks :WAVE:
zoef at 2007-11-11 20:56:32 >