我想一個C字符串保存到我的密碼類的實例,我不斷收到錯誤消息申請非類類型的成員
request for member 'assign' in 'Password::password', which is of non-class type '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)'。 – chris
C字符串沒有成員。 – Rapptz
也許你的意思是'passwrd.assign(word);'。 –