vendredi 25 janvier 2019

Use cases of keyword using in C++11

I know using in C++11 behaves same as typedef. I have this code and found different use cases:

template<typename T, int a>
class Base
{
public:
     std::vector<T> noise_(a);
     using VectorType = std::vector<T>;
     virtual VectorType getVector() const
     {
        return noise_;
     }
protected
     VectorType noise_;
};

template<typename T, int a> 
class Derived : public Base<T,a>
{
    public:
        using Base<T,a>::noise_;
        using VectorType = typename Noise<T,a>::VectorType; 
        using Noise<T,a>::getVector;
};

Here, using is used in 3 different way. What is the purpose of the following line (noise_ is a protected member of the base class):

Base<T,a>::noise_;

Same for:

using Noise<T,a>::getVector;

Aucun commentaire:

Enregistrer un commentaire