错误LNK2019:尝试可视化现有consol项目时未解析的外部符号

时间:2016-03-05 23:15:04

标签: c++ winapi

我有一个用C ++编写的程序仓库。我需要使用WinAPI将其可视化。 我用Menu列表创建了中央DialogBox,根据所选按钮应该调用不同的方法。 我将所有需要的头文件包含在stdafx.h中

#include "targetver.h"

#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>

// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include"ConstructMaterials.h"
#include"Visitor.h"

Ny项目名称是Sklad,所以在Sklad.cpp中我创建了全局对象,它代表仓库和类访问者(我使用这种模式)来定义这些商品应属于哪个部门。

 Warehouse w;
 Visitor v(w);

对于ex,我想显示库存中的所有当前商品。为此,我调用类Warehouse方法:

INT_PTR CALLBACK MainScreen(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);
    switch (message)
    {
    case WM_INITDIALOG:
            w.loadExistingData();
        return (INT_PTR)TRUE;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
        {
            EndDialog(hDlg, LOWORD(wParam));
            return (INT_PTR)TRUE;
        }
        if(LOWORD(wParam) == IDC_BUTTON3)
        {
            DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hDlg, Show);
        }
        break;
    }
    return (INT_PTR)FALSE;
}
被调用的方法看起来像那样:

void Warehouse::loadExistingData()
{
    Visitor v(*this);
    Goods*cement=new ConstructMaterials();
    cement->SetGoods("cement", 20, "Ukraine", "tn", 2016, 1, 25);
    cement->AddMe(v);
    Goods*pen=new OfficeStuff();
    pen->SetGoods("pen", 50, "Poland", "pcs", 2020, 1, 1);
    pen->AddMe(v);
    Goods*ink=new OfficeStuff();
    pen->SetGoods("ink", 50, "Finland", "pcs", 2016, 2, 17);
    pen->AddMe(v);
    Goods*Laundry=new HomeAppliances();
    Laundry->SetGoods("laundry", 2, "China", "pcs", 2017, 11, 2);
    Laundry->AddMe(v);
    Goods*microwave=new HomeAppliances();
    microwave->SetGoods("microwave", 5, "France", "pcs", 2014, 5, 8);
    microwave->AddMe(v);
    Goods*metal=new ConstructMaterials();
    metal->SetGoods("metalPipes", 50, "Russia", "tn", 2030, 1, 1);
    metal->AddMe(v);
}

但是在编译期间我遇到了一个错误: 1&gt; Sklad.obj:错误LNK2019:未解析的外部符号&#34; public:void thiscall Warehouse :: loadExistingData(void)&#34; (?loadExistingData @ Warehouse @@ QAEXXZ)在函数&#34; int __stdcall MainScreen中引用(struct HWND *,unsigned int,unsigned int,long)&#34; (?MainScreen @@ YGHPAUHWND __ @@ IIJ @ Z) 1&gt; E:\ Sklad \ Debug \ Sklad.exe:致命错误LNK1120:1个未解析的外部 仓库的标题看起来:

#ifndef W
#define W
//#include"Goods.h"
#include<vector>
#include<fstream>
#include"ConstructMaterials.h"
#include"HomeAppliances.h"
#include"OfficeGoods.h"
//#include"Visitor.h"
//class Visitor;

class Warehouse
{
public:
    vector<ConstructMaterials>constructMaterials;
    vector<OfficeStuff>officeStuff;
    vector<HomeAppliances>homeAppliances;
    //Warehouse();
    void Menu();
    void Show();
    void loadExistingData();
    void Insert();
    void DispatchGoods();
    void GoodsThatValidOneWeek();
    void ReviewExpiredGoods();
    void SaveToFile();
    void LoadDataFromFile();
    //~Warehouse();
};


#endif

我在google光盘上保存了这个项目,所以如果它有助于解决这个问题,那么我将会很快。

我完全失去了如何管理它。

提前致谢。

0 个答案:

没有答案