Undefined reference error C++
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 开发者_如何学PythonA::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
}
From your edit it seems you're missing the public:
part before static void FunA()
.. did you just forget to edit it in or maybe it's really missing in your .cpp?
Have you included the right .lib
file, if necessary?
You should always initizalize static functions and variables in cpp file before using
Is it possible that you have double declaration in your code, because this would give you a compiler error.
精彩评论