在使用new分配对象内部使用'new'分配内存是否有任何影响?编译器,链接器,运行时性能或其他方面是否有优势或劣势?动态分配对象内的动态分配
什么我谈论
class IntData
{
public:
IntData()
{
IntVector = new std::vector<int>();
//...
}
protected:
std::vector<int> *IntVector; //Would this be any different to static allocation if...
};
//...I know that all IntData objects will be dynamically allocated
IntData *object = new IntData();
'intVector的=新的std ::矢量();'没有任何好处超过只是说'的std ::矢量 IntVector;' –
使用* IntVector只是添加一个间接的水平....就是这样。 – sunny1304
没有使用这种方法的问题。作为性能,运行时间 - 这取决于最终的设计和算法,很难说 – NirMH