I've borrowed example from this question. There are following files:
main.cpp
#include <iostream>
#include "foop.h"
int main(int argc, char *argv[])
{
int x=42;
std::cout << x <<std::endl;
std::cout << foo(x) << std::endl;
return 0;
}
foop.h
#ifndef FOOP_H
#define FOOP_H
int foo(int a);
#endif
foop.cpp
int foo(int a){
return ++a;
}
As you can see main.cpp includes foop.h, but foop.h contains only declaration not definition of function foo. How does main.cpp knows about existence of foop.cpp and the definition of foo function? My first guess was that if the name of *.h is the same as of *.cpp then it somehow magically works, but it also worked when I've renamed foop.cpp to foop2.cpp
PS: I keep files under one project, inside same directory inside Visual Studio
PPS: Can I somehow debug the compilation process so I can see what is going on?