Creep2DJ Creep2DJ - 1 year ago 70
C++ Question

If I #include a header file in a non-main source file, do I need to also do that in the main file?

I have a file

, in which
is #included. Do I need to include in
as well? Or may I leave it alone?

Answer Source

You need to add #include <algorithm> to main.cpp if main.cpp uses any functions or classes, or anything else that's defined in <algorithm>.

What some other translation unit uses is irrelevant.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download