【发布时间】:2015-01-18 05:36:36
【问题描述】:
我使用 insert() 方法将一个 Image 对象传递给我的哈希表。
htImages.insert(WALL_UP_CLOSE, imgWalls[WALL_UP_CLOSE]);
如您所见,我通过引用将对象传递给 Value。
void insert(const Key &key, const Value &value)
{
Entry entry;
int index;
// Build up entry structure
entry.m_key = key;
entry.m_value = value;
// Build the insertion index
index = m_hash(key) % m_size;
// Insert the value
m_table[index].append(entry);
m_count++;
}
然而,一旦这个函数在最后一行结束,下面的析构函数就会被调用。
Image::~Image()
{
glDeleteTextures(1, &m_handle);
refCount--;
}
我的偏好是不调用析构函数。我是通过引用传递的,为什么要调用析构函数呢?
【问题讨论】:
-
怎么样你通过了吗?向我们展示代码。事实上,所有相关的代码。
-
Image与第一个代码示例有什么关系? -
显示
Entry的定义,m_table的类型,以及调用该函数的代码。 -
您正在创建
Key和Value子对象以及entry -
嗯,这是我列出的我们需要看到的三件事之一。
标签: c++