i accessed a static function(funA()) in class A (all function in this class is static) but getting Undefined reference error. I included header
Please help.
// H file
Class A
{
static void funA();
};
// Cpp file
void A::funA() { }
Accessed in class B
void B::funB()
{
A::funA()
}
Make sure you have something like this on your header:
// a.h
class A {
static void funA();
};
// a.cpp
void
A::funA() {
// do something on your function
}
从您的编辑看来,您似乎缺少public:
在static void FunA()
..之前的部分,您是否只是忘了对其进行编辑,或者您的.cpp中确实缺少它?
如有必要,您是否包含正确的.lib
文件?
使用前,您应始终在cpp文件中初始化静态函数和变量
您的代码中是否可能有双重声明,因为这会给您带来编译器错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.