I’m very new to C++ and coding in general, this is supposed to be a start to a password manager being made using classes and this part in particular was a master password the user sets and then has to enter again but the “mpw.FmasterPassword();” line gives “too few arguments in function call” error and I have looked up how to solve this error but nothing matches
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
class Student
{
private:
string UserUsername;
string UserPassword;
string MasterPassword;
public:
string Uname[100];
string Pword[100];
void setDetails(string Mpassword) {
MasterPassword = Mpassword;
}
void FmasterPassword(string Masterp, string Imasterp, Student Mpassword) {
cout << "Set your master password: ";
cin >> Masterp;
Mpassword.setDetails(Masterp);
Emp:
cout << "Enter the mater password: ";
cin >> Imasterp;
if (Imasterp == Masterp) {
cout << "Correct" << endl;
}
else
cout << "That was incorrect" << endl;
goto Emp;
}
};
int main() {
Student Mpassword;
Student mpw;
string Masterp;
string Imasterp;
mpw.FmasterPassword();
return 0;
}
ive tried putting all my definitions into the main but that didnt work
your function is
FmasterPassword(string Masterp, string Imasterp, Student Mpassword)
, but you called it likempw.FmasterPassword()
. Notice the difference?For the love of (deity), do not use
goto
Because folks are going to nag at you over that
goto
for the rest of your life, kill it. You can easily replace it with any loop and areturn
on success.Looks like you have confused parameters with local variables and misunderstood how a method’s instance variable (
this
) gets into the method. I recommend reviewing the early chapters of your C++ text. If you do not have a C++ text, you are almost certainly fated to an ill doom. Avoid failure by getting and reading a good beginners text.I deleted my comment about passing parameters because there are other fundamental problems with the code. I question if you wanted FmasterPassword() to have parameters in the first place. Also I am unsure why Mpassword is a Student and not just a
std::string
Show 1 more comment