【发布时间】:2013-07-23 03:10:07
【问题描述】:
我正在尝试将 C 字符串保存到我的 Password 类的实例中,但我不断收到错误消息
请求'Password::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();
}
我真的很茫然。
【问题讨论】:
-
使用
std::string和: password(word)。 -
C 字符串没有成员。
-
也许你的意思是
passwrd.assign(word);。
标签: c++