【发布时间】:2010-12-15 05:36:08
【问题描述】:
在 C++ 中,定义未使用的附加方法或函数是否会导致更大的内存占用或更慢的执行速度?
基本上,我在一个类中有几个实用程序调试方法,这些方法都不是该类的正常使用所必需的。如果这些定义从未使用过,它们是否会在内存占用或速度方面有所不同?例如:
class myClass
{
public:
//Something the user of this class would use
int doSomething() {...}
//Something used solely to make sure I wrote the class properly
bool isClassValid() {...}
};
...
myClass classInstance();
myClass.doSomething();
【问题讨论】:
-
Windows,但这个问题适用于任何平台。
-
这个问题适用于任何平台,是的。答案因平台而异。在内存管理方式和应用程序结构方面,嵌入式 RMX 将与大型机操作系统大不相同。
标签: c++ c language-agnostic memory performance