出于好奇,如果您将方法定义放在 header 中的类定义中,并且编译器没有内联它,那么在链接器阶段该方法被放入哪个或哪些目标文件以供访问?它是否放在每个包含 header 的 .obj 文件中,然后在链接器阶段丢弃额外的拷贝?
最佳答案
Is it put in every .obj file that includes the header, and then extra copies are thrown away during the linker phase?
一般来说,是的。 See this paper.
关于C++ 链接类定义中定义的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6230048/