C++ Programmer Question:
Explain me what do you mean by translation unit in c++?
Answer:
We organize our C++ programs into different source files (.cpp, .cxx etc). When you consider a source file, at the preprocessing stage, some extra content may get added to the source code ( for example, the contents of header files included) and some content may get removed ( for example, the part of the code in the #ifdef of #ifndef block which resolve to false/0 based on the symbols defined). This effective content is called a translation unit. In other words, a translation unit consists of
☛ Contents of source file
☛ Plus contents of files included directly or indirectly
☛ Minus source code lines ignored by any conditional pre processing directives ( the lines ignored by #ifdef,#ifndef etc)
☛ Contents of source file
☛ Plus contents of files included directly or indirectly
☛ Minus source code lines ignored by any conditional pre processing directives ( the lines ignored by #ifdef,#ifndef etc)
Previous Question | Next Question |
Tell me when you should use virtual inheritance? | Tell us in how many ways we can initialize an int variable in C++? |