First of all, in C++,
class and
struct are the same, except that the
default visibility of members is "private" for
classes and "public" for
structs. By convention, I would recommend to use
struct for POD (plain-old-data), and
class for all other types that are
not POD.
https://www.educative.io/answers/what-are-plain-old-data-pod-types-in-cpp
In your code, the class
Artifacts is
declared in
Artifacts.h, and its methods as well the the constructor are
implemented (defined) in
Artifacts.cpp. Maintaining the declaration and the implementation of a class in separate files is a standard approach in C++.
The class
Artifacts also declares two "nested" classes (structs), called
sAABuffer and
sAABuffer_Helper.
______
The
constructor of
Artifacts, i.e.
Artifacts::Artifacts(), simply calls the (private) method
Artifacts::Init(). That method creates a
new instance of
sAABuffer, which will invoke the constructor of
sAABuffer, i.e.
sAABuffer::sAABuffer(). Also note that, in
Artifacts::Init(), the pointer to the newly created
sAABuffer instance is stored in the member variable
Artifacts::m_AABuffer. Last but not least, the destructor, i.e.
Artifacts::~Artifacts() is going to destroy the
sAABuffer instance in
Artifacts::m_AABuffer.
______
I think this code in invalid/dangerous:
auto AAPacketBuffer = reinterpret_cast<DWORD>(this->m_Artifacts->m_AABuffer);
That is because
m_Artifacts->m_AABuffer is a
pointer to an
sAABuffer instance, i.e. it has type
sAABuffer*. What is the purpose of reinterpret-castling this pointer to
DWORD? Also, on 64-Bit operating systems, this will
truncate the 64-Bit pointer to 32-Bits !!!
If you
really need to store a pointer as an integral type, then at least use the
DWORD_PTR type! But why is the cast needed at all? 😕