有人可以为我解释以下代码片段吗?
// Bind base object so we can compute offsets
// currently only implemented for indexes.
template<class DataObj> void BindAsBase(DataObj &rowbuf)
{
// Attempting to assign working_type first guarantees exception safety.
working_type = DTL_TYPEID_NAME (rowbuf);
working_addr = reinterpret_cast<BYTE*>(&rowbuf);
working_size = sizeof(rowbuf);
}
我的问题是 sizeof(rowbuf) 的结果是什么?是 DataObj 的长度还是 Byte* 的长度?为什么?
另一个问题:为什么需要计算指针的偏移量?它的一般用途是什么?
sizeof(working_addr) 等于多少?