在VC7里,怎么调用一个类里的函数?
在VC7里,如何调用一个类里的函数??
***************.h头文件*********************
#pragma once
// myInterface
class myInterface
{
public:
myInterface();
virtual ~myInterface();
int test(int a,int b);
protected:
};
***************.cpp文件*********************
// Interface.cpp : 实现文件
//
#include "stdafx.h "
#include "myInterface.h "
// Interface
myInterface::myInterface()
{
}
myInterface::~myInterface()
{
}
int test(int a,int b)
{
return a+b;
}
我在MFC按钮的click事件里这样调用
void CliverobotDlg::OnBnClickedButton2()
{
myInterface *myi=new myInterface();
this-> MessageBox((LPCTSTR)myi-> test(1,2));
}
编译的时候出错
错误 1 error LNK2019: 无法解析的外部符号 "public: int __thiscall myInterface::test(int,int) " (?test@myInterface@@QAEHHH@Z),该符号在函数 "public: void __thiscall CliverobotDlg::OnBnClickedButton2(void) " (?OnBnClickedButton2@CliverobotDlg@@QAEXXZ) 中被引用 liverobotDlg.obj
错误 2 fatal error LNK1120: 1 个无法解析的外部命令 D:\程序源码\Visual Studio 2005\liverobot\Debug\liverobot.exe 1
如果我把头文件改成这样,就没问题
***************.h头文件*********************
#pragma once
// myInterface
class myInterface
{
public:
myInterface();
virtual ~myInterface();
int test(int a,int b)
{
return a+b;
}
protected:
};
------解决方案--------------------
把CPP文件加到工程里面来。
------解决方案--------------------
兄弟加油啊!
------解决方案--------------------
改为
myInterface::~myInterface()
{
}
int myInterface::test(int a,int b)
{
return a+b;
}
------解决方案--------------------
把CPP文件加到工程里面来。
------解决方案--------------------
加进来
------解决方案--------------------
继续汗
------解决方案--------------------
无言
------解决方案--------------------
汗..
***************.h头文件*********************
#pragma once
// myInterface
class myInterface
{
public:
myInterface();
virtual ~myInterface();
int test(int a,int b);
protected:
};
***************.cpp文件*********************
// Interface.cpp : 实现文件
//
#include "stdafx.h "
#include "myInterface.h "
// Interface
myInterface::myInterface()
{
}
myInterface::~myInterface()
{
}
int test(int a,int b)
{
return a+b;
}
我在MFC按钮的click事件里这样调用
void CliverobotDlg::OnBnClickedButton2()
{
myInterface *myi=new myInterface();
this-> MessageBox((LPCTSTR)myi-> test(1,2));
}
编译的时候出错
错误 1 error LNK2019: 无法解析的外部符号 "public: int __thiscall myInterface::test(int,int) " (?test@myInterface@@QAEHHH@Z),该符号在函数 "public: void __thiscall CliverobotDlg::OnBnClickedButton2(void) " (?OnBnClickedButton2@CliverobotDlg@@QAEXXZ) 中被引用 liverobotDlg.obj
错误 2 fatal error LNK1120: 1 个无法解析的外部命令 D:\程序源码\Visual Studio 2005\liverobot\Debug\liverobot.exe 1
如果我把头文件改成这样,就没问题
***************.h头文件*********************
#pragma once
// myInterface
class myInterface
{
public:
myInterface();
virtual ~myInterface();
int test(int a,int b)
{
return a+b;
}
protected:
};
------解决方案--------------------
把CPP文件加到工程里面来。
------解决方案--------------------
兄弟加油啊!
------解决方案--------------------
改为
myInterface::~myInterface()
{
}
int myInterface::test(int a,int b)
{
return a+b;
}
------解决方案--------------------
把CPP文件加到工程里面来。
------解决方案--------------------
加进来
------解决方案--------------------
继续汗
------解决方案--------------------
无言
------解决方案--------------------
汗..