功能声明与定义混淆 [英] confusion in function declaration vs defination
本文介绍了功能声明与定义混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是CPP的新手。声明和功能定义之间非常混淆。
这里是我的代码
文件名:pcanlinkerclass.cpp
pCANLinkerClass :: pCANLinkerClass()
{
LoadAPI();
}
void pCANLinkerClass :: LoadAPI()
{
mypcanlinkerfunction();
qDebug()<< 第一条消息;
}
void pCANLinkerClass :: mypcanlinkerfunction()
{
qDebug() << 第二条消息;
}
给我错误mypcanlinkerfunction未在范围内声明。
我不知道这段代码有什么问题吗?以及如何使其正常运行。
任何帮助都将不胜感激。
解决方案
必须有一个具有相同名称和签名的方法在pCANLinkerClass
类声明中(通常在头文件中),例如
in pCANLinkerClass头文件
类 pCANLinkerClass
{
// ...
void mypcanlinkerfunction();
// ...
};
Hi I am new in CPP. very confused between declaration and defination of function.
here is my code
file name: pcanlinkerclass.cpp
pCANLinkerClass::pCANLinkerClass()
{
LoadAPI();
}
void pCANLinkerClass::LoadAPI()
{
mypcanlinkerfunction();
qDebug() << "first message";
}
void pCANLinkerClass::mypcanlinkerfunction()
{
qDebug() << "second message";
}
giving me error "mypcanlinkerfunction" not declared in the scope.
I dont know whats wrong with this code? and how to make it functional.
any help would be appreciated please.
解决方案
There must be a method with the same name and signature in thepCANLinkerClass
class declaration (usually in the header file), e.g.
in pCANLinkerClass header file
class pCANLinkerClass { //... void mypcanlinkerfunction(); //... };
这篇关于功能声明与定义混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文