I have a component class that doesn't have a default constructor and needs an object passed to it instead. I want to have a template class that builds a stack space, arbitrarily sized array of this component. Because it doesn't and really shouldn't have a default constructor, I'm running into issues making it work. Another note on the template class is that it can only have one parameter passed to it, and it must use it to initialize all of the array's elements.
Relevant parts of the component I want to create the array of.
class CSomeComponent : public CComponent {
public:
CSomeComponent(const IObject* pObject) : CComponent(pObject) {
}
};
Relevant parts of the template array I'm trying to make work.
template<size_t _Count>
class CComponentArray {
public:
CComponentArray(const IObject* pObject) : m_component(...) {
}
private:
CSomeComponent m_component[_Count];
};
I can't change the fact that components don't have a default constructor. I also can't give the component array template more than one parameter. These two constraints are why I can't figure out how I'd do this, so hopefully someone else can. Thank you!