Include headers in header file?

前端 未结 3 393
春和景丽
春和景丽 2021-01-04 21:55

I have several libraries made by myself (a geometry library, a linked list library, etc). I want to make a header file to include them all in one lib.h. Could I do something

3条回答
  •  孤街浪徒
    2021-01-04 22:20

    Yes, this works, and is in fact used in most APIs. Remember what a #include actually does (tell the preprocessor to immediately include a new file), and this should make sense. There is nothing to prevent several levels of inclusion, although implementations will have a (large) maximum depth.

    As noted, you should organize your headers into logical groupings.

提交回复
热议问题