Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 错误:应为表达式&;预期的不合格id_C++ - Fatal编程技术网

C++ 错误:应为表达式&;预期的不合格id

C++ 错误:应为表达式&;预期的不合格id,c++,C++,我正在构建一个应用程序,它做了一件事。。。Ya boi正在尝试实现一个密码功能,允许用户在新用户时创建密码,或者在返回用户时输入密码(所有数据都写入/读取到名为UserData.txt的txt文件中),编译器会不断返回下面列出的错误。我在Google上到处找都找不到,我想这可能与声明字符串的Password变量有关,但我不知道如果是这样的话,为什么它需要一个表达式。我对编码相当陌生,所以代码有点马虎,但这里有一些错误,我似乎无法理解: 代码: ./Privacy/Password.hpp:25:

我正在构建一个应用程序,它做了一件事。。。Ya boi正在尝试实现一个密码功能,允许用户在新用户时创建密码,或者在返回用户时输入密码(所有数据都写入/读取到名为UserData.txt的txt文件中),编译器会不断返回下面列出的错误。我在Google上到处找都找不到,我想这可能与声明字符串的
Password
变量有关,但我不知道如果是这样的话,为什么它需要一个表达式。我对编码相当陌生,所以代码有点马虎,但这里有一些错误,我似乎无法理解:

代码:

./Privacy/Password.hpp:25:17: error: expected unqualified-id
string Password = " ";
                ^

./Privacy/Password.hpp:33:23: error: expected expression
  UserData >> Password;
                      ^
                      
./Privacy/Password.hpp:35:30: error: expected expression
  if (OldPassword != Password) 
                             ^
                   
./Privacy/Password.hpp:39:36: error: expected expression
    while (PasswordTemp != Password) 
                                   ^

./Privacy/Password.hpp:53:20: error: expected expression
    cin >> Password;
                   ^
main.cpp


    #include <iomanip>
    #include "math.h"
    #include <string>
    #include <iostream>
    #include <fstream>
    #include <sstream>
    #include "Privacy/Password.hpp"
    
    using namespace std;
    
    //Variable Prototypes
    
    //Function Prototypes
    void display();
    void CreatePassword();
    
    
    //Main Function
    int main()
    {
      cout << "\t\t\t~~Welcome to Tegridy Pharmaceuticals!~~" << endl;
      CreatePassword();
    }

宏定义

    #define Password
意味着在此之后代码中的任何令牌
密码
,都应替换为空字符串

因此,它阻止您将标识符
密码
用作变量


您应该为include-guard指定另一个名称。

请考虑一下预处理器将如何处理类似于
#define Password
string Password=“OldPassword”的内容一次通过。一切都清楚了吗?是的,我知道你要去哪里了。XD感谢您的帮助当我确保包含警卫时,我会确保使用一个我永远不会使用的名称,例如,我会使用类似以下内容:
PASSWORD\u H
而不是
PASSWORD
正式注明;谢谢你的建议。哇,我真是太无知了。谢谢你的帮助!
    #define Password