Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 模板参数的缩写(Vector3而不是Vector<;3>;)_C++_Templates - Fatal编程技术网

C++ 模板参数的缩写(Vector3而不是Vector<;3>;)

C++ 模板参数的缩写(Vector3而不是Vector<;3>;),c++,templates,C++,Templates,考虑一个模板 template<int size> class Vector{ public: double data[size]; } 而不是 Vector<3> a; 向量a; 对于size?的常规值,如果您特别需要专门化,只需使用typedef: using Vector3 = Vector<3>; 使用Vector3=Vector; 如果您特别需要专门化,只需使用typedef: using Vector3 = Vector<3>

考虑一个
模板

template<int size>
class Vector{
public:
  double data[size];
}
而不是

Vector<3> a;
向量a;

对于
size

的常规值,如果您特别需要专门化,只需使用typedef:

using Vector3 = Vector<3>;
使用Vector3=Vector;

如果您特别需要专门化,只需使用typedef:

using Vector3 = Vector<3>;
使用Vector3=Vector;

最直接的例子是
类型定义向量3

最直接的例子是
typedef Vector3

否。您可以在模板中使用的唯一类型是
class
typename
(它们现在是等效的)。@ciuak No,int是模板中的有效类型。否。您可以在模板中使用的唯一类型是
class
typename
(它们现在是等效的)。@ciuak No,int在模板中是有效的类型。是否也有可能使用常规大小?@Matthias No.
Vector3
是一个标识符,必须首先声明。虽然有一些方法使用
typedef Vector#size
或类似的东西..是否也有通用大小的可能性?@Matthias No.
Vector3
是一个标识符,必须首先声明。认为有一些方法使用
typedef Vector#size或类似的东西。。