this is an unusual error, but maybe if the code presented here it's easier to recognize?!

void sLetter(Word_store& s)
{
    for ((s.words_input)::iterator it = (s.words_input).begin();
         it != (s.words_input).end(); ++it)
        tolower(*it);

    (s.sWords).push_back(s.words_input);

    return;
}

the function is aim to converting each character in a string from a member of Word_store into lowercase letter.

struct Word_store
{
    std::string words_input;
    std::vector<std::string> Words, CWords, sWords;
};

above code is obvious, but the question is why this error occured?

error: expected ';' before '::' token.
error: 'it' was not declared in this scope.

Recommended Answers

error: expected ';' before '::' token.

You have to get the iterator from the class, not an instance. Try this:

for (std::string::iterator it = (s.words_input).begin();

error: 'it' was not declared in this scope.

This one disappears once you fix the above problem.

Jump to Post

All 2 Replies

error: expected ';' before '::' token.

You have to get the iterator from the class, not an instance. Try this:

for (std::string::iterator it = (s.words_input).begin();

error: 'it' was not declared in this scope.

This one disappears once you fix the above problem.

commented: thnx +0

lol facepalm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.