Consider a file functions.cpp:
// functions.cpp
void f1(){/* do something */}
void f2()
{
f1();
}
I wish to use the function f2 is a different cpp file, so I create a header file functions.h:
// functions.h
#ifndefine F2
#define F2
void f2();
#endif
Now, the main.cpp file is where I call f2:
// main.cpp
#include "functions.h"
int main()
{
f2();
return 0;
}
Compiling this works fine, but I haven't declared f1 in functions.h. So when f2 is called, how does the compiler know about f1?
Aucun commentaire:
Enregistrer un commentaire