I have an abstract (template) class tXmlNode
from which I have derived the template class tXmlGeometry
. This derived class shall be constructed with a pointer to an object of varying type hence it is created as a template. This object shall be transferred to the derived class via a pointer.
My current implementation of the constructor of the derived class is as follows (I leave out the scope implementation as it is not relevant to my question I think):
nXml::tXmlGeometry<Part>::tXmlGeometry(Part* part) : tXmlNode<Part>(part)
My compiler (MS VisualStudio 2019) accepts this. But it also accepts that:
nXml::tXmlGeometry<Part>::tXmlGeometry(Part* part) : tXmlNode<Part>(*part)
What is the exact difference here? As far as I understand it the second one calls the constructor of the abstract class and transfers the content of part
to this tXmlNode
constructor whereas the first one does what?
Now I am currently creating an abstract class tXmlSegment
that inherits from tXmlGeometry
.
The constructor for this new abstract class is formulated as follows:
nXml::tXmlSegment2D::tXmlSegment2D(tXmlGeometry<Part>* geo, const int npos) : tXmlGeometry<Part>(*geo), position(npos)
What is curious is that my compiler now insists of getting the dereferenced geo
object and I don't understand the reason for that. Why is it so that I have to dereference it?
EDIT: The constructor of tXmlNode is as follows:
template<class Node>
inline tXmlNode<Node>::tXmlNode(
Node* node,
const int npos) : xml_doc(nullptr), node(node), n_childs(0), n_attr(0), position(npos)