Reputation: 85
For example #include "example.h, example2.h, example3.h"
instead of #include
3 times on 3 lines.
Is this possible?
It came up on a test and I was wondering.
Upvotes: 2
Views: 634
Reputation: 238321
Can I #include multiple header files?
Yes. You can do that using multiple include directives.
For example, #include "example.h, example2.h, example3.h" Instead of #include 3 times on 3 lines
Not in practice. Technically, the C++ language doesn't really specify how the path maps to a "file" does it specify what a "file" is, so you could have a theoretical language implementation where you could do something like that. But such language implementation doesn't exist to my knowledge, nor would using such trick be portable to actually existing systems.
You'll need multiple include directives to include multiple files.
Upvotes: 1
Reputation: 7220
No the include
preprocessing directive, only takes a single file, see: https://en.cppreference.com/w/cpp/preprocessor/include
The question is, would it really benefit you to merge includes to a single line. I would guess having includes on separate lines, makes managing them easier.
So basically you can include any number of files, but only one per include
directive.
Upvotes: 3