我正在尝试为我使用的Poco函数编写包装类。从基类继承函数声明中参数的默认值
这里是我的代码:
//PocoWrapper.h
#include <stdio.h>
#include <Poco/Task.h>
#include <Poco/TaskManager.h>
#include <Poco/ThreadPool.h>
namespace myNamespace{
class ThreadPool : Poco::ThreadPool{};
}
现在,如果我有PocoWrapper.h在另一个剧本,我应该能够使用:
myThreadPool = new myNamespace::ThreadPool(1,4);
但是这给了错误:
//error: C2661: 'myNamespace::ThreadPool::ThreadPool' : no overloaded function takes 2 arguments
但是,如果我使用:
myThreadPool = new Poco::ThreadPool(1,4);
它编译得很好。因此,问题一定是它不会继承Poco :: ThreadPool类中的函数的默认值。
ThreadPool构造函数具有默认值,所以它应该只能使用2个参数。从documentation:
ThreadPool(
int minCapacity = 2,
int maxCapacity = 16,
int idleTime = 60,
int stackSize = 0
);
我怎样才能让我的包装类的工作只有两个参数,如基类呢?
我没有使用C++ 11。
方法是继承_but_构造函数是一种特殊情况。请看看[SO:继承构造函数](https://stackoverflow.com/a/434784/7478597)。由于这与Poco无关,因此它看起来像是重复的。 – Scheff
你不需要公共继承吗? – danielspaniol
[继承构造函数]可能的重复(https://stackoverflow.com/questions/347358/inheriting-constructors) – Scheff