What is the logic behind the "using" keyword in C++?

Viewed 165271

What is the logic behind the "using" keyword in C++?

It is used in different situations and I am trying to find if all those have something in common and there is a reason why the "using" keyword is used as such.

using namespace std; // to import namespace in the current namespace
using T = int; // type alias
using SuperClass::X; // using super class methods in derived class
2 Answers

Another difference between typedef and using: you may do this:

    using vector3d_t = double[3];
    vector3d_t v = {1,2,3};
    v[1] = 4;

It is not possible with typedef:

    typedef double[3] vector3d_t; // Compilation error
Related