This code is redundant in the assignment and CopyCtor:
vertices = source.vertices;
indices = source.indices;
MaterialID = source.MaterialID;
m_Transform = source.m_Transform;
maybe there should be a private shallowSubclassCopy() method provided that does prevent code duplication:
Mesh::Mesh( const Mesh &source ) :
BaseMesh(source)
{
shallowSubclassCopy(source);
}
Mesh& Mesh::operator=( const Mesh& source )
{
// copy members from base class EntityObject
EntityObject::operator=(source);
// copy additional member from this class
shallowSubclassCopy(source);
return *this;
}
void shallowSubclassCopy( const Mesh &source )
{
vertices = source.vertices;
indices = source.indices;
MaterialID = source.MaterialID;
m_Transform = source.m_Transform;
}
maybe you can make this optional with a checkbox:
[x] Create private shallowSubclassCopy Method to prevent code duplication
It is also common to use "copy swap" to implement the assignment operator - this works like this:
class string
{
public:
// ...
string &string::operator=(const string &source)
{
string temp( source ); // first make a copy of the source object
// now swap the internals of the copy with this object
std::swap( temp.str, str );
// just do the same for other internals members
std::swap( temp.m_ID, ID);
std::swap( temp.m_Transform, m_Transform);
// and so on...
return *this;
// destructor of temp is called - str pointer of tmp is deallocated
}
// ..
private:
char* str;
};
maybe the user can choose with a radio control which variant should generated:
( ) Memberwise Copy
(*) Copy Swap