3.Create a class called Password that represents the password for a user account
ID: 3667966 • Letter: 3
Question
3.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.
I need this in C++ not java.
Explanation / Answer
#include<iostream.h>
#include<string.h>
class Password
{
public:
char password[20];
Password()
{
password="";
}
char[] get()
{
return password;
}
void set(char[] p)
{
int a=strcmp(password,p)
if(strlen(p)<8 || a==0)
{
cout<<"No Password change";
}
else
{
strcpy(password,p);
}
}
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.