[英]array initialization requires a brace-enclosed initializer list
My class Matrix4x4
has a constructor that takes 9 values and copies them into an internal T value[4][4]
member through an initializer list. 我的Matrix4x4
类具有一个构造函数,该构造函数接受9个值,并通过初始化列表将它们复制到内部T value[4][4]
成员中。 However, it doesn't compile, and I'm not entirely sure why. 但是,它不能编译,我也不完全知道为什么。 Specifically, the error says: array initialization requires a brace-enclosed initializer list
. 具体来说,该错误表明: array initialization requires a brace-enclosed initializer list
。
I'm using Visual Studio 2015. 我正在使用Visual Studio 2015。
template<typename T>
Matrix4x4<T>::Matrix4x4(
T aa, T ba, T ca,
T ab, T bb, T cb,
T ac, T bc, T cc
)
: value({
{ aa, ba, ca, 0 },
{ ab, bb, cb, 0 },
{ ac, bc, cc, 0 },
{ 0, 0, 0, 1 }
})
{
}
If you have access to a C++11 compiler, here's one solution. 如果您可以使用C ++ 11编译器,则这里是一种解决方案。
Remove the (
and )
from the initializer of value. 从值的初始值设定项中删除(
和)
。 Use: 采用:
Matrix4x4::Matrix4x4(T aa, T ba, T ca,
T ab, T bb, T cb,
T ac, T bc, T cc)
: value{ { aa, ba, ca, 0 },
{ ab, bb, cb, 0 },
{ ac, bc, cc, 0 },
{ 0, 0, 0, 1 } }
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.