My have three .cpp
files and their headers.
//a.cpp
#include "a.h"
#include "b.h"
void A::foo() {
C c;
c.bar();
}
//a.h
#include "b.h"
class A {
public:
void foo();
};
//b.h
#include "c.h"
//c.h
#pragma once
class C {
public:
void bar();
};
//c.cpp
#include "c.h"
void C::bar() {}
//other files are ignored
But when I compiled them, I got this error:
a.cpp:(.text+0xb1): undefined reference to `C::bar()`
Have I included c.h
through b.h
? Why doesn't it work?