Re: Template multiple inheritance Organization: Roundhouse Consulting, Ltd.
On 2011-05-17 12:46:37 -0400, dec4106 said:
I can't figure out how to differentiate between the PortProvider
interfaces. Here's sort of what I want to do:
template <typename T>
struct Provider
{
virtual ~Provider() {}
virtual T getValue() const = 0;
};
template <typename T, int port>
struct PortProvider : public Provider<T>
{
virtual ~PortProvider() {}
virtual T getValue() const { return getPortValue(); }
virtual T getPortValue() const = 0;
};
class ConcreteProvider : public PortProvider<double, 1>, public
PortProvider<int, 2>
{
public:
virtual double getPortValue(); // return value for port 1
virtual int getPortValue(); // return value for port 2
};
Is there a notation that distinguishes the two templates? Thanks.
Sure. Do the same thing you'd do if you had two non-template bases.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]