Visual Studio Windows 从其他类调用函数

发布于 2024-12-12 10:07:29 字数 1901 浏览 0 评论 0原文

我正在开发一个小型的 Visual stdio 2010 C++ 项目。我创建了一个基于 Windows 的小型项目。 GUI界面有一些按钮。然后我创建了一个 xxx.h 和 xxx.cpp 文件,其中包含一些小函数。现在我想在有人按下按钮时调用 xxx 的函数。我收到以下错误请帮助我......

1>EagleTool.obj : error LNK2028: unresolved token (0A0000CF) "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$$FSMXXZ) referenced in function "private: void __clrcall EagleGUI::Form1::button3_Click(class System::Object ^,class System::EventArgs ^)" (?button3_Click@Form1@EagleGUI@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>EagleGUI.obj : error LNK2028: unresolved token (0A00000B) "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$$FSMXXZ) referenced in function "private: void __clrcall EagleGUI::Form1::button3_Click(class System::Object ^,class System::EventArgs ^)" (?button3_Click@Form1@EagleGUI@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>EagleGUI.obj : error LNK2019: unresolved external symbol "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$$FSMXXZ) referenced in function "private: void __clrcall EagleGUI::Form1::button3_Click(class System::Object ^,class System::EventArgs ^)" (?button3_Click@Form1@EagleGUI@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>EagleTool.obj : error LNK2001: unresolved external symbol "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$$FSMXXZ)

EagleTool.h

#ifndef _EagleTool_H_
#define _EagleTool_H_
class EagleTool {

  public:
    void static extractCorrectPathofEagle();

 };

#endif

EagleTool.cpp

#include "stdafx.h"

#include "EagleTool.h"
#include "Form1.h"

void static extractCorrectPathofEagle(){

}

I am developing a small visual stdio 2010 c++ project. I have created a small windows based project. The GUI interface have some buttons. Then I have created a xxx.h and xxx.cpp file with some small function. Now I want to call a function fom xxx, when some one press the button. I am getting following error please help me....

1>EagleTool.obj : error LNK2028: unresolved token (0A0000CF) "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$FSMXXZ) referenced in function "private: void __clrcall EagleGUI::Form1::button3_Click(class System::Object ^,class System::EventArgs ^)" (?button3_Click@Form1@EagleGUI@@$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>EagleGUI.obj : error LNK2028: unresolved token (0A00000B) "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$FSMXXZ) referenced in function "private: void __clrcall EagleGUI::Form1::button3_Click(class System::Object ^,class System::EventArgs ^)" (?button3_Click@Form1@EagleGUI@@$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>EagleGUI.obj : error LNK2019: unresolved external symbol "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$FSMXXZ) referenced in function "private: void __clrcall EagleGUI::Form1::button3_Click(class System::Object ^,class System::EventArgs ^)" (?button3_Click@Form1@EagleGUI@@$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>EagleTool.obj : error LNK2001: unresolved external symbol "public: static void __clrcall EagleTool::extractCorrectPathofEagle(void)" (?extractCorrectPathofEagle@EagleTool@@$FSMXXZ)

EagleTool.h

#ifndef _EagleTool_H_
#define _EagleTool_H_
class EagleTool {

  public:
    void static extractCorrectPathofEagle();

 };

#endif

EagleTool.cpp

#include "stdafx.h"

#include "EagleTool.h"
#include "Form1.h"

void static extractCorrectPathofEagle(){

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别在捏我脸啦 2024-12-19 10:07:29

您需要在定义中包含类名:

static void EagleTool::extractCorrectPathofEagle() {
    // ...
}

否则您将定义一个完全不相关的函数,而该函数恰好具有相同的名称。

You need to include the class name in the definition:

static void EagleTool::extractCorrectPathofEagle() {
    // ...
}

Otherwise you're defining an entirely unrelated function that just happens to have the same name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文