undefined reference to是什么意思
来源:百度知道 编辑:UC知道 时间:2024/05/30 23:41:32
一个类中定义:inline double getLambda()const
{
cout<<lambda_;
return lambda_;
}
其他类调用getLambda的时候显示undefined reference to‘类名::getLambda()const’或者more undefined reference to‘类名::getLambda()const’
详细的错误提示:
调用函数的类名.o:In function '_ZN18调用函数的类名S17出错的函数名EP8定义函数的类名S1_':
调用函数的类名.cc:某行:undefined reference to‘定义函数的类名::getLambda()const’
umtsnode.h:
inline double getLambda()const;
调用:
WalfischIkegamiLoS.h:
#include <umtsnode.h>
WalfischIkegamiLoS.cc:
#include "walfischikegamilos.h"
double WalfischIkegamiLoS::PropagationLosses(UmtsNode* t,UmtsNode* r){
lambda = t->getLambda(); // wavelength
{
cout<<lambda_;
return lambda_;
}
其他类调用getLambda的时候显示undefined reference to‘类名::getLambda()const’或者more undefined reference to‘类名::getLambda()const’
详细的错误提示:
调用函数的类名.o:In function '_ZN18调用函数的类名S17出错的函数名EP8定义函数的类名S1_':
调用函数的类名.cc:某行:undefined reference to‘定义函数的类名::getLambda()const’
umtsnode.h:
inline double getLambda()const;
调用:
WalfischIkegamiLoS.h:
#include <umtsnode.h>
WalfischIkegamiLoS.cc:
#include "walfischikegamilos.h"
double WalfischIkegamiLoS::PropagationLosses(UmtsNode* t,UmtsNode* r){
lambda = t->getLambda(); // wavelength
我很想知道你的类怎麼写的,和如何掉用的
其实完全没有必要这样写
如果是类成员函数,会默认内联的.
比如我在Test.H中
定义
#pragma once
class Test
{
public:
int a;
int test() const;
};
Test.cc中就可以:
#include "test.h"
int Test::test() const
{
return 0;
}
main.cc
#include "test.h"
void main()
{
Test t;
t.test();
}
这样比较好.