对myclass :: myfunction错误的未定义引用 [英] Undefined reference to myclass::myfunction error
本文介绍了对myclass :: myfunction错误的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开始学习QT了。做小学习的任务。我收到错误未明确引用mymainwindow :: mytestfunctiontocall
这里是我的代码我是怎么做的
in mywindwindow.h < br $>
I am starting to leran QT. doing small tasks for learning. I am getting error "Undefined reference to mymainwindow::mytestfunctiontocall"
here is my code how i am doing
in mymainwindow.h
public
void mytesfunctioncall();
in mywindwindow.cpp
in mymainwindow.cpp
void myMainwindow::on_Push_Button_clicked()
{
mytestfunctiontocall()
}
mytestfunctiontocall()
{
qDebug() << "Hello world msg";
}
推荐答案
Quote:
public
void mytesfunctioncall();
public
void mytesfunctioncall();
这是无效的 C ++
代码。
如果你发布实际代码会更好,以获得适当的帮助。
This is not valid C++
code.
It is better if you post the actual code, in order to get proper help.
大部分代码都是错的,你应该花更多的时间学习C ++在尝试学习Qt之前。
假设您的头文件包含myMainwindow
的正确类声明,那么.cpp文件应该类似于跟随,并使用标题中声明的相同方法名称:
Most of that code is wrong, you should spend more time studying C++ before trying to learn Qt.
Assuming that your header file contains a proper class declaration formyMainwindow
, then the .cpp file should look something like the following, and use the same method name as declared in the header:
void myMainwindow::on_Push_Button_clicked()
{
mytesfunctioncall();
}
void myMainwindow::mytesfunctioncall()
{
qDebug() << "Hello world msg";
}
这篇关于对myclass :: myfunction错误的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文