2015-03-13 82 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)