I would like to provide access to an existing type from base class inside child class.
I found two different ways :
struct A {
typedef int mytype;
};
struct B {
typedef double mytype;
};
I can "include" the type with a using declaration :
struct C : A, B {
using typename A::mytype;
};
Or I can create a type alias :
struct C : A, B {
typedef A::mytype mytype;
using mytype = A::mytype; //C++11
};
- Is there any difference ?
- What are the pros and cons of each syntax ?
- Which one is the most used/recommended ?
Thank you.
Related question : Using-declaration of an existing namespace type vs creating a type alias