2015-03-13 91 views
0

所以我使用登錄來編程菜單。 登錄階段檢查用戶和密碼是否與數據庫中的用戶和密碼匹配(phpMyAdmin)。VS中的C++:錯誤LNK 2019未解決的符號錯誤

但是我的函數出錯,我不知道爲什麼。

這是我的主要(CPP):

// Kassasysteem.cpp : Defines the entry point for the console application. 
// 

#include "stdafx.h" 
#include <tchar.h> 
#include "KlassenVerzameling.h" 


using namespace std; 

int inloggen(); 
void menu(int userID); 


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

#ifdef User_Offline 
    admin.Init(); 
#endif 
    UserDAO gebruikers; 
    int userID = 0; 
    bool doorgaan = true; 

    while (doorgaan) 
    { 
     userID = inloggen(); 

     cout << "Welkom " << gebruikers.getUser(userID)->getGebr_naam() << "!" << endl << endl; 
    } 

    return 0; 
} 

int inloggen(){ 
    UserDAO users; 

#ifdef User_Offline 
     users.Init(); 
#endif 

     string naam, wachtwoord; 

     cout << "Gebruikersnaam (leeg om af te sluiten)? "; 
     getline(cin, naam); 

     if (naam.empty()) 
     { 
      return -1; 
     } 
     else { 
      wachtwoord = hiddenline("Wachtwoord? "); 
      cout << "Verificatie gebruiker..."; 
      User* gebruiker = users.getUserByName(naam); 

      if (gebruiker == 0) 
      { 
       return -2; 
      } 
      else { 
       if (gebruiker->getWachtwoord() == wachtwoord) 
       { 
        return gebruiker->getUserID(); 
       } 
       else { 
        return -2; 
       } 
      } 
     } 

#ifdef User_Offline 
     users.Dispose(); 
#endif 

} 

,我宣佈我的函數頭文件(我使用的密碼校驗):

#ifndef SPECIALEINVOER_H_INCLUDED 
#define SPECIALEINVOER_H_INCLUDED 


string hiddenline(string prompt, char masker = '*'); 
void setXY(int, int); 
int wherex(); 
int wherey(); 

#endif 

而且在.cpp文件我的密碼檢查過程的功能編程:

#include "stdafx.h" 
#include "specialeInvoer.h" 

HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); 

string hiddenline(string prompt, char masker) 
{ 
    string wachtwoord; 
    cout << prompt; 
    int x = wherex(); 
    int y = wherey(); 
    char c = _getch(); 

    while (c != 13) //13 = ENTER 
    { 
     if (c == 8) //backspace 
     { 
      if (!wachtwoord.empty()) 
      { 
       wachtwoord.pop_back(); 
       setXY(--x, y); 
       cout << " "; 
       setXY(x, y); 
      } 
     } 
     else { 
      wachtwoord.push_back(c); 
      cout << masker; 
      x++; 
     } 
     c = _getch(); 
    } 
    cout << endl; 
    return wachtwoord; 
} 

我沒有語法錯誤只有這些類型錯誤:(對於函數whereex,wherey和setXY)。

Error 5 error LNK2019: unresolved external symbol "int __cdecl wherex(void)" ([email protected]@YAHXZ) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl hiddenline(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char)" ([email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z)  

一些幫助將是巨大的,我已經潛伏在stackover相當長的一段時間,但大多是我看到沒有真正幫助我的答案奇怪的答案。

THX

+1

wherex()實現的代碼在哪裏?你需要以某種方式將它包含在你的項目中。 – 2015-03-13 14:46:45

+0

它在我的cpp文件中。 – 2015-03-13 15:13:23

+0

它不在你顯示的代碼中,也可能是鏈接器看不到它。 ;) – 2015-03-13 15:18:39

回答

1

正如評論說:

你的功能wherexwhereysetXY在代碼中未實現。 您已實施hiddenline,爲什麼不是其他人?

另外你的功能setXY(int, int)應該是setXY(int a, int b)