I hope somebody can help me to understand why I cannot access certain members of my abstract base class tXmlNode
. I've searched StackOverflow and the net and could not really identify why it's not working. Admittingly I am pretty new to C++.
So here is a shortened code of my abstract base class
template<class Node>
class tXmlNode
{
public:
tXmlNode();
tXmlNode(Node* node, const int npos = 1);
tXmlNode(const tXmlNode& rhs); //copy constructor
tXmlNode(tXmlNode&& rhs); //move constructor
tXmlNode& operator=(const tXmlNode& rhs); //assignment operator
//need to do move assignment operator. Not an issue at this stage.
virtual ~tXmlNode();
pugi::xml_node GetNode();
int GetChildNumber();
protected:
Node* node;
pugi::xml_node this_node = pugi::xml_node();
pugi::xml_node parent_node = pugi::xml_node();
int n_childs;
int position;
}
;
I derive several classes from this one, some of them themselves abstract classes.
A shortened version of my tXmlGeometry<Part>
class:
template<class Part>
class tXmlGeometry : public tXmlNode<Part>
{
public:
tXmlGeometry();
tXmlGeometry(Part* part);
~tXmlGeometry();
pugi::xml_node GetParentNode();
protected:
std::string parent_id;
};
From my base class I also derived another abstract class tXmlSegment2D
:
template<class Part>
class tXmlSegment2D : public tXmlNode<tXmlGeometry<Part>>
{
public:
tXmlSegment2D();
tXmlSegment2D(tXmlGeometry<Part>* geo, const int npos);
virtual ~tXmlSegment2D();
std::string GetSegmentType();
protected:
std::string segment_type;
}
;
from which I further derive my tXmlStraightLine
class:
template<class Part>
class tXmlStraightLine : public tXmlSegment2D<Part>
{
public:
tXmlStraightLine(tXmlGeometry<Part>* geo, const int npos);
~tXmlStraightLine();
}
;
The implementation of this class is as follows:
template<class Part>
inline nXml::tXmlStraightLine<Part>::tXmlStraightLine(
tXmlGeometry<Part>* geo,
const int npos) : tXmlSegment2D(geo, npos)
{
this->position = 0;
parent_node = geo->GetNode();
}
;
template<class Part>
inline nXml::tXmlStraightLine<Part>::~tXmlStraightLine()
{
}
;
So what is really weird is that I get an error message for tXmlStraightLine
such as that parent_node
qualifier could not be found. It doesn't complain about position
though.
I thought maybe the grandchild "tXmlStraightLine" cannot take directly from its grandparent. But I've made something similar already which works and I cannot find why that latter works and this one doesn't.
(I have an abstract class class tXmlPart : public tXmlNode<tXmlCaseDefinition>
and class tXmlShape : public tXmlPart
, this lineage works fine. For completeness: class tXmlCaseDefinition : public tXmlNode<tXmlCaseDefinition>
).