Original Post
Hi. I was wondering if somebody could help me with this bit of code. I have a templated class A, that takes a non-type parameter for a simple array dimension. And I have a class B that needs to hold a certain class A based on unrelated values. How can I have a templated member when its type is unknown? I don't want class B parameterized, and I'd rather not have class A inherit from a base class, but these seem to be my only options. If anyone as any insight into this, I'd appreciate it greatly. Thanks.
template< unsigned int array_size = 3 >
class A {
unsigned char array_[ array_size ];
unsigned int array_size_;
public:
A(): array_( new unsigned char[array_size] ), array_size_( array_size ) {};
};
class B {
A<?> a_;
public:
B( int arbitrary, int vars ) {};
};