3 ms·
> The compiler says anything you declare though needs to be defined. No it doesn’t. If that were true dynamic linking would not be a thing, but it’s not even t
by epcoa 2y ago
> The compiler says anything you declare though needs to be defined.
No it doesn’t. If that were true dynamic linking would not be a thing, but it’s not even true in the most basic way either.
> Basically defined before use.
Also not true. But this is “not even wrong” since “before use” isn’t defined here, however if it is meant to be appears before in the input, then that is wrong.
> The one rule the linker needs is hey is this declared before you use it. That way the linker can eventually find the right code to call.
Because of the way C++ is defined this is somewhat true (not so much for incomplete types), but also a tortured avoidance of the compiler role (Translation phase 7) in the process, and really the meat of what is going on. I’d recommend someone just read cppreference first.
https://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-declaration https://stackoverflow.com/questions/1410563/what-is-the-diff...