Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is is standard practice to have the same include derivate in a header and source file?

When working with say, the standard strings class in c++. Do you need to have #include<string> on both the header and source file?

can you not just have #include<string> only on the header file?

like image 762
Adeeb Avatar asked Dec 26 '22 09:12

Adeeb


1 Answers

Including on the header file may indicate a dependency at the class definition level (for example you are accepting or returning Strings). In this case you have to put the include in the header; however if you are only using Strings in your implementation you may need to include only on the source file.

like image 102
Otávio Décio Avatar answered Feb 02 '23 00:02

Otávio Décio