I have the following template class
template <typename threadFuncParamT >
class ThreadPool
{
// number of threads to be launced initially and added to thread pool.
ThreadPool( pThreadFunc pFunction, RtsInt16_t minThreads, RtsInt16_t maxThreads, RtsInt16_t maxExecCount);
};
Now i want to use object of another class
struct myStruct
//...
};
class MyClass
{
private:
ThreadPool<myStruct *> pool;
};
My question is how to create ThreadPool with constructor arguments in MyClass constructor as I don’t have default constructor?
Assuming you mean “as I don’t have default constructor in
ThreadPool:Assuming you mean “as I don’t have default constructor in
MyClass:MyClasshas a default constructor as long as you either provide your own or you do not provide any other constructor. As it is in your question, it has a compiler-generated default constructor. Of course, that wouldn’t compile, because the compiler-generated default constructor would simply call the default constructors of all (base classes and) data members, and the only data memberpoolis of a class that doesn’t provide a default constructor.So you need to provide your own default constructor, as shown in the example above.