Consider the code below:
//header.h
#pragma once
class A
{
public:
A();
void f();
};
//header.cpp
#include "header.h"
A::A(){}
void A::f(){}
//main.cpp
#include "header.h"
int main()
{
A a;
a.f();
}
So how the compiler knows where exactly is the declaration of the constructor
and f
function, because only the header.h
in included in main.cpp
? And why cant it find the same functions when the class A
is template??