错误调用vc ++方法错误LNK2019:函数_wmain

时间:2016-07-05 16:26:16

标签: visual-studio-2010 express visual-c++ linker

显示错误调用对象的vc ++ 2010 express sp1方法:

  

错误LNK2019:未解析的外部符号" public:int __thiscall   OPER :: ShowMyResult(无效)" (?ShowMyResult @ oper @@ QAEHXZ)引用于   function _wmain

ooad_oops_exer.h

#include "stdafx.h"
class oper {
public:
void DisplayDefault( );
void DisplayWidth( int n );
void DisplayLongs( );
 int ShowMyResult();
};

ooad_oops_exer.cpp

#include "ooad_oops_exer.h"
//
#ifndef SOCKET_CLIENT_CLASS
#define SOCKET_CLIENT_CLASS

const double   d1 = 1.23456789;
const long   l1 = 16;
int base = 10;

void oper::DisplayDefault( )
{
   cout << endl << "default display" << endl;
}
void oper::DisplayWidth( int n )
{
   cout << endl << "fixed width display set to " << n << ".\n";
}
void oper::DisplayLongs( )
{
   cout <<endl<<"hello";
}
int oper::ShowMyResult()
{
   DisplayWidth(15);
   DisplayDefault( );

   cout <<endl<<"ShowMyResult";
   return   0;
}
//
#endif

的main.cpp

#include "stdafx.h"
#include "ooad_oops_exer.h"


int _tmain(int argc, _TCHAR* argv[])
{
    oper op;
    int k = op.ShowMyResult();
    cin.get();

    return 0;
}

修改

  

1&GT;生成代码... 1&gt; Debug \ ooad_oops_exer.obj:警告LNK4042:   对象指定不止一次;附加设备忽略1&gt; main.obj:错误   LNK2019:未解析的外部符号&#34; public:int __thiscall   OPER :: ShowMyResult(无效)&#34; (?ShowMyResult @ oper @@ QAEHXZ)引用于   function _wmain 1&gt; C:\ xxx \ OOAD_OOPS_PROJ \ Debug \ OOAD_OOPS_PROJ.exe:   致命错误LNK1120:1个未解析的外部1>

0 个答案:

没有答案