CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Sep 2010
    Posts
    34

    Error in function 'int main()":

    Can anyone tell me what this error is? Never saw it before my int main() is there but it keeps saying that. I also get changePassword was not declared in this scope , what does that mean?

    In function 'int main()':

    #include <iostream>
    #include <string>
    #include <fstream>
    using namespace std;

    class UserAccount
    {
    private:
    string userName;
    string userPassword;
    string userID;
    string password;
    string oldPassword;
    string newPassword;


    public:
    //constructor
    UserAccount ( string userID, string password)
    {
    userName = userID;
    userPassword = password;
    }

    //login
    bool login (string userID,string password)
    {

    if(userName == userID && userPassword == password)
    {
    cout << "True" << endl;
    }
    else {
    cout << "False" << endl;
    }

    } //end login


    //ChangePassword
    void changePassword ( string oldPassword, string newPassword)
    {
    if (oldPassword == password)
    {
    password = newPassword;
    }
    else {
    cout << "wrong" << endl;
    }
    }
    }; //end class

    int main ()
    {
    string userID;
    string password;

    UserAccount account (userID, password);

    cout << "What is your Username?" <<endl;
    cin >> userID; //user enter username

    cout << "Enter your Password?" <<endl;
    cin >> password; //user enter password


    if (account.login(userID, password))
    changePassword(password, "random_password");


    system("pause");
    }
    Last edited by Eialvare; September 29th, 2010 at 08:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured