私はクラスの割り当てに取り組んでおり、関数でブール型を定義した後、「{」の「予期された非修飾 ID」を取得し続けています。このエラーが発生する理由がわかりません。プログラムを実行できずに割り当てを完了するのが難しくなっています。このエラーが発生する理由を誰か教えてもらえますか? これが私のコードです
//Page 825 Problem 12
#include <iostream>
#include <string>
using namespace std;
//Function Prototype
bool testPassword(char []);
const int passLength = 21;
char password[passLength];
int main()
{
//Ask user to enter password matching the following criteria
cout << "Please enter a password at six characters long. \n"
<< "Password must also contain at least one uppercase and one lowercase letter. \n"
<< "Password must also contain at least one digit. \n"
<< "Please enter your password now \n";
cin.getline (password, passLength);
if (testPassword(password))
cout << "Password entered is of the correct format and has been accepted.";
else
cout << "Password does not meet criteria \n";
return 0;
}
//*******************************
//**Function to test password ***
//**to determine if it meets ***
//**criteria listed ***
//*******************************
//Test password to determine if it is at least six characters long
bool testPassword (char password[]);
bool lower;
bool upper;
bool digit;
bool length;
{
if (strlen(password) < 6)
length = true;
else
length = false;
cout << "Password must be at least 6 characters long.\n";
for (int k = 0; k < passLength; k++)
{
if (islower(password[k])
lower = true;
else
lower = false;
cout << "Password must contain a lowercase letter.\n";
if (isupper(password[k])
upper = true;
else
upper = false;
cout << "Password must contain an uppercase letter.\n";
if (isdigit(password[k])
digit = true;
else
digit = false;
cout << "Password must contain a digit.\n";
}
if (lower && upper && digit && length == true)
return true;
else
return false;
}