C++ help Create a class called Password that represents the password for a user
ID: 3668554 • Letter: C
Question
C++ help
Create a class called Password that represents the password for a user account. The class should have at least one string data member representing the password and the following member functions:
A constructor that creates an empty password.
Get function that returns the current password.
Set function that changes the current password to a given string. This function should not change the password if the new string is less than 8 characters in length or if the new string is the same as the previously set password. A new data member may be required to implement this!
Explanation / Answer
#include<iostream.h>
#include<string.h>
class Password
{
public:
char p[15];
int a;
Password()
{
p="";
}
char[] get()
{
return p;
}
void set(char[] p1)
{
a=strcmp(p,p1);
if(strlen(p)>8 && a!=0)
strcpy(p,p1);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.