Where # include headers?

I looked at sample header files, but I could only find simple ones that didn't contain anything.

So my question is: where am I #includestuff like stringand vector? In a .h or .cpp file? Or maybe in both?

+4
source share
2 answers

Everywhere.

If you need something declared in the header file, include them in the .h file. Otherwise, just in the .cpp file.

, .h - , .h , . #include. , , , .

, , , , .h, , , . , ( .cpp .h). , .

: " - , ", , .

+5

# , ? .h .cpp?

, (.. , ).

:

  • , ( std::string API, string ++)

  • , (.. "" - .h, .h, ).

  • . , ++, std boost , () , , std.

    , std- / API ( ). std, (), , , include . , std cpp.

+2

All Articles