Error 1 error LNK2019: unresolved external symbol "public: void __thiscall Login::loginMenu(void)

StackOverflow https://stackoverflow.com/questions/20928341

  •  24-09-2022
  •  | 
  •  

문제

I searched through the website and there were answers about default constructor or using #pragma. but I'm using #pragma in my visual studio and I tried to debug but any of those methods didnt work. Please tell where I have made the mistake. Thank you

this is my main,

#include "stdafx.h"
#include<iostream>

#include "Login.h"


using namespace std;




int _tmain(int argc, _TCHAR* argv[])
{

Login log;
log.loginMenu();


std::cin.get();
return 0;
} 

login.h is as following, #pragma once

class Login
{
public:
void loginMenu();
};

and the Login.cpp file,

#include "stdafx.h"
#include "Login.h"

#include<iostream>
#include<string>

using namespace std;


void loginMenu()
{
int userType;

do{

    cout << "Select 1 for STAFF" << endl;
    cout << "Select 2 for HR MANAGER" << endl;
    cout << "Select 3 for ADMINISTRATOR" << endl;

    cout << "Please select your usertype";
    cin >> userType;


    switch(userType){
    case 1:
        cout << "You have selected STAFF";
        break;
    case 2:
        cout << "You have selected HR MANAGER";
        break;
    case 3:
        cout << "You have selected ADMINISTRATOR";
        break;
    default:
        cout << "Please make your choice by selecting from 1-3";
    }
}while(userType==1,userType==2,userType==3);


}

This is a simple program I created to demonstrate "using classes in separate files.

도움이 되었습니까?

해결책

You have declared, and are calling, a function Login::loginMenu - a member function of class Login - but you haven't implemented it. You have implemented a function ::loginMenu - a non-member stand-alone function - but you are not calling it.

Make it

void Login::loginMenu() {...}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top