undefined reference to a static function

You forgot to prefix the definition with the class name :

#include "a.h"

void A::funcA(int i) {
     ^^^
//Add the class name before the function name
    std::cout << i << std::endl;
}

The way you did things, you defined an unrelated funcA(), ending up with two functions (namely A::funcA() and funcA(), the former being undefined).


#include "a.h"

void funcA(int i) {
    std::cout << i << std::endl;
}

should be

#include "a.h"

void A::funcA(int i) {
    std::cout << i << std::endl;
}

Since funcA is a static function of your class A. This rule applies both to static and non-static methods.

Tags:

C++