// Just to check that everyrhing can be compliled template class list { }; ///////////////// // DirGraph template class Vertex { public: typedef typename C::Edge Edge; // functionality protected: list edges; }; template class Edge { public: typedef typename C::Vertex Vertex; // functionality protected: Vertex* first; Vertex* second; }; template class Graph { public: typedef typename C::Vertex Vertex; typedef typename C::Edge Edge; // functionality and algorithms protected: list vertices; list edges; }; struct GraphConfig { typedef Vertex Vertex; typedef Edge Edge; }; Graph graph; ///////////////// // DirGraph template class DirVertex: public Vertex { public: //{} type \Cls{Edge} is inherited //{} extended functionality protected: // a new internal staff }; template class DirEdge: public Edge { public: //{} type \Cls{Vertex} is inherited Vertex* source() const { return m_first; } Vertex* target() const { return m_second; } // more functionality protected: // a new internal staff }; template class DirGraph: public Graph { public: //{} types \Cls{Vertex} and \Cls{Edge} are inherited //{} new functionality and algorithms protected: // a new internal staff }; struct DirGraphConfig { typedef DirVertex Vertex; typedef DirEdge Edge; }; DirGraph dirGraph; /////////////////////////////// // Face template class FaceEdge : public DirEdge { public: //{} role \Cls{Vertex} is inherited typedef typename C::Face Face; Face* getFace() const { return face; } // more functionality protected: Face* face; }; template class Face { public: typedef typename C::Edge Edge; // functionality and algorithms protected: list edges; }; template class FaceGraph: public DirGraph { public: //{} roles \Cls{Vertex} and \Cls{Edge} are inherited typedef typename C::Face Face; // new functionality and algorithms protected: list faces; }; struct FaceGraphConfig { typedef DirVertex Vertex; typedef FaceEdge Edge; typedef Face Face; }; FaceGraph faceGraph; Face aFace; void main() { }