I’m getting a too few arguments in function call error and not sure why? [closed]

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

  • 6

    your function is FmasterPassword(string Masterp, string Imasterp, Student Mpassword), but you called it like mpw.FmasterPassword(). Notice the difference?

    – 

  • 5

    For the love of (deity), do not use goto

    – 




  • 3

    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 a return on success.

    – 




  • 3

    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.

    – 

  • 1

    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

    – 




Leave a Comment