Templates & Inheritance - Danger of Ambigiousness?

Hi, folks!

I was programming & eventually ran into a situation, which isn't very self-explanatory for me. Allow me to demonstrate:

1
2
3
4
5
6
7
template<class T>
class Foo{
public:
    // Methods
protected:
    T data;
};


Here's a simple template class that contains a member variable data. Now, the situation I find problematic is like the following:

class Foo2 : public Foo<SomeObject>, public Foo<AnotherObject>

This is the start of a class declaration, which inherits from the template class Foo twice bit differently. Now, how can I know, which data member variable I'm calling inside class Foo2? I find it quite ambitious.
Last edited on
You can write Foo<SomeObject>::data and Foo<AnotherObject>::data to differentiate.
Wow, simple problems have simple solutions.

Thank you, Peter87! Your name will now be put into the source code.
Topic archived. No new replies allowed.