Josephat
Josephat

Reputation: 21

Is there any alternative for auto &c in c++

I am a beginner and new to this platform. I am trying to run a program to test a valid password with uppercase, lowercase letters and at least one number. Part of the program is...

bool hasUpperCase(const string password)
{
    for (auto &c : password)
    {
        if (isupper(c))
            return true;
    }
    return false;
}

I have tried compiling the whole program with my compiler which is Falcon C++ but it keeps giving me this error

'auto' will change meaning in C++0x; please remove it

How can I remove it and what is its alternative?

The program runs on other compilers such as Onlinegdb.com and C++ shell

Upvotes: 0

Views: 300

Answers (1)

Hatted Rooster
Hatted Rooster

Reputation: 36483

You're using an outdated (version of your) compiler, this compiler acknowledges breaking changes coming in C++11 which was standardized 10 years(!) ago. Every modern compiler compiles at least with C++11 as base which would remove this error.

The easy and only good solution is to update your compiler, if you for some reason can't do that then change it to char& (but actually please just update).

Upvotes: 4

Related Questions