template <typename T>
class B
{
public:
using ID = size_t;
protected:
int x;
};
template <typename T>
class C : public B <T>
{
public:
ID id; // error - does not name a type
typename B<T>::ID id; // works but very ugly
void setX()
{
this->x = 5;
}
private:
};
When I wish to use the type ID (declared in class B) in class C then I need to use typename B<T>::ID - this is very ugly and cumbersome so I wondered whether there is a less ugly way of doing it. Is it normal just to have a using statement:
template <typename T>
class B
{
public:
using ID = std::size_t;
};
template <typename T>
class C : public B <T>
{
usingtypename B<T>::ID ;
ID id = 1 ; // fine
};