Suppose we have a hierarchy of abstract classes:
/* Item | | ------- Object | |------ Link */ For example:
class Item { public: World *world() = 0; }; //----------------------------------------------- class Object : public Item { public: virtual ObjectValue calculate() = 0; virtual void connectTo(const QString &objectId, const QString &linkDefId) = 0; }; //----------------------------------------------- class Link : public Item { public: virtual QString fromObjectId() const = 0; virtual QString toObjectId() const = 0; virtual QString linkDefId() const = 0; }; And here it is necessary to implement the Object and Link classes. For example, a family of client classes:
class ClientObject : public Object { //... }; //----------------------------------------------- class ClientLink : public Link { //... }; and server class family:
class ServerObject : public Object { //... }; //----------------------------------------------- class ServerLink : public Link { //... }; Then how to implement the World *Item::world() function, if it should work only inside the class of implantation Client[ClassName] and the same inside Client[ClassName] , but differ between the Server[ClassName] and Server[ClassName] ? (It is assumed that other families can be inherited and for each of them the World *Item::world() function should be implicitly the same for classes within this family.)
For example, in Java, the problem would be solved by using different words for the inheritance of implements and extentds . How can I get out of C ++? Of course, it is possible to describe ClientObject::world() and ClientLink::world() identically, but you understand that this is non-kosher.
ClientObjectandClientLinkshould be the same and the same forServerObjectandServerLink, but, for example, betweenClientXxxandServerXxxwill differ (I will edit the question to clarify this point) - asianirish