c++ linker error : undefined reference to a static function

隐身守侯 提交于 2020-01-22 02:24:12

问题


A.h file

class A{
      public:
      static int* func (int &b);
}

A.cpp

int* A::func(int &b){
   //some definition here
}

I am calling the above function in some other file. I have included the .h file in that. When I try to compile I get the following error

undefined reference to A::func(int &)


回答1:


The code looks right.

The first thing to check is that your build environment compiled and linked in A.cpp.



来源:https://stackoverflow.com/questions/12399453/c-linker-error-undefined-reference-to-a-static-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!