首页 文章

请求非类型成员

提问于
浏览
0

我正在尝试将C字符串保存到我的Password类的实例中,并且我不断收到错误消息

请求'密码::密码'中的成员'assign',这是非类型'char [80]'

以下是与错误相关的代码部分:

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>

using namespace std;

class Password
{
    const static string too_short;
    const static string no_upper;
    const static string no_lower;
    const static string no_digit;
    const static string no_punct;

    string end_message;
    int score;
    char password[80];
    string passwrd;

    public:
        Password (char word[])
        {
            password.assign(word);
            c_stringCheck();
        }

我真的很茫然 .

2 回答

  • 0

    字符数组不要试图在一个上调用 assign . 也许使用 strcpystrncpy ,非标准的 strlcpy ,或者是惯用的C等价物 .

  • 0

    password只是一个char数组 . 所以你不能所有的password.assign()函数 . 试试strcpy!

相关问题