C++中"using“关键字背后的逻辑是什么?
它在不同的情况下使用,我试图找出是否所有这些都有共同之处,这也是为什么使用"using“关键字的原因。
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
发布于 2021-09-02 12:37:26
类型定义和使用的之间的另一个不同之处是:您可以这样做:
using vector3d_t = double[3];
vector3d_t v = {1,2,3};
v[1] = 4;
这是不可能的,但使用typedef:
typedef double[3] vector3d_t; // Compilation error
https://stackoverflow.com/questions/20790932
复制相似问题