I've checked posts here that I can use template for nested struct. But when I'm trying to initialize an array inside a nested struct, there seems problem during initialization. In the following example, the array size is one of the parameters of the nested struct so Visual Studio complained that the array size is illegal. Here is the definition:
//template<typename U, typename T>
template<typename U, size_t T> // this line also not work
struct A {
struct B {
struct C {
vector<U> count[T]; // count needs to have variable size
C() {
count = new U[T]; // allocate size. Not work
}
C c;
};
B b;
};
Did I do anything wrong when using the template and initialize the array?
Thanks