First, let me show you the struct:
struct HPOLY
{
HPOLY() : m_nWorldIndex(0xFFFFFFFF), m_nPolyIndex(0xFFFFFFFF) {}
HPOLY(__int32 nWorldIndex, __int32 nPolyIndex) : m_nWorldIndex(nWorldIndex), m_nPolyIndex(nPolyIndex) {}
HPOLY(const HPOLY& hPoly) : m_nWorldIndex(hPoly.m_nWorldIndex), m_nPolyIndex(hPoly.m_nPolyIndex) {}
HPOLY &operator=(const HPOLY &hOther)
{
m_nWorldIndex = hOther.m_nWorldIndex;
m_nPolyIndex = hOther.m_nPolyIndex;
return *this;
}
bool operator==(const HPOLY &hOther) const
{
return (m_nWorldIndex == hOther.m_nWorldIndex) && (m_nPolyIndex == hOther.m_nPolyIndex);
}
bool operator!=(const HPOLY &hOther) const
{
return (m_nWorldIndex != hOther.m_nWorldIndex) || (m_nPolyIndex != hOther.m_nPolyIndex);
}
__int32 m_nPolyIndex, m_nWorldIndex;
};
There are some things I don’t understand.
What does the repetition of HPOLY inside the struct mean? And how to transcript structs to delphi code?
Thank you for your help.
The repetition of HPOLY inside the struct are definitions of constructors for that type. In Delphi, the copy constructor (the third one in the C++, which constructs an instance of this type based on another instance of the same type) not necessary in Delphi. The two-argument constructor lets you specify initial values for the two fields. The default, zero-argument constructor sets the fields’ values to -1, but Delphi doesn’t allow such a constructor on records.
The next section in that struct is the assignment operator. Delphi provides that for records automatically. Next are comparison operators that compare the type for equality and inequality. The compiler will invoke them when you use the
=and<>operators onHPolyvalues.