BUG: C2233 on User-Defined Type Array Member of Template ClassID: Q216977
|
When compiling a template class that contains a data member that is an array of a second template class, and the second class contains a data member that is an array, and the size of both arrays is dependent on a template parameter, you will receive the following error:
error C2233: '<Unknown>' : arrays of objects containing zero-size arrays are illegal
Use a pointer instead of an array. Allocate the space for the array in the constructor and deallocate the space for the array in the destructor.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
template <int k>
class A
{
char x[k];
};
template <int h, int j>
class B
{
A<h> y[j];
};
template <int k>
class A
{
char *x;
A() {
x = new char[k];
}
~A() {
delete[] x;
}
};
template <int h, int j>
class B
{
A<h> y[j];
};
Additional query words:
Keywords : kbCompiler kbCPPonly kbVC600bug
Version : winnt:6.0
Platform : winnt
Issue type : kbbug
Last Reviewed: February 19, 1999