Re: Constructors and virtual inheritance...
DeCaf wrote:
What is the recommended way of handling this?
I post an example below that illustrates what I mean if the text above
did not quite clarify it:
The important question is how much of the code are you free to modify.
The relationships you are creating appear to be non-elegant. If we
have freedom to make some changes this would be much cleaner:
// concrete class with functionality we want to inherit
class Node
{
public:
Node(const std::string &id) : mId(id)
{
std::cout << "Node with id " << id << " created\n";
}
private:
std::string mId;
};
// abstract interface
class DependerNode
{
public:
virtual void bar() = 0;
};
// abstract interface
class DependeeNode
{
public:
virtual void bar2() = 0;
};
// inherit the concrete functionality and implement two abstract
interfaces
class ExpressionNode : public DependerNode, public DependeeNode, public
Node
{
public:
ExpressionNode(const std::string &id) : Node(id) {}
void bar() {}
void bar2() {}
};
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]