Is there any way to "uninclude" a file in C++?

The effect of unincluding a header half way through a code file, into which you have included the header at the file start, is supposed to be that the code in the second half acts as if the header has not been included.

This can be achieved by splitting the code file into two parts.
First part includes the header in question (and probably some other headers).
Second part does NOT include the header (but the others again, so that their content IS known).

You might have to put anything from the first half which needs to be visible in the second half into a new header and also include that into both parts.

So in short, create two code files and include what you need into them. Especially do not include what you do not want to be visible.


No.

Part of this is that includes are part of the preprocessor. For the actual compiler, code from an included file and code from the including file look the same.

Tags:

C++

Class