C++/boost : use tuple ctors when subclassing

标签 c++ boost constructor initialization tuples

有没有办法像这里一样使用 boost 元组的 ctors 作为对子类方法(和 ctors)的补充?

// typedef boost::tuple<int, SomeId, SomeStatus> Conn;
// Conn(1); // works and initializes using default ctors of Some*
struct Conn : boost::tuple<int, AsynchId, AccDevRetStatus> {};
Conn(1); // "no matching function call" (but i want it so much)

T.H.X.

最佳答案

您必须自己定义所有构造函数并转发给基类。

请注意,您可以创建一个 typedef。

typedef boost::tuple<int, AsynchId, AccDevRetStatus> Conn;

关于C++/boost : use tuple ctors when subclassing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3014800/

相关文章:

C++ "system(command)"不适用于 NetBeans/Windows

c++ - 在所有线程未完成时 boost 线程打印一些东西

java - 重载的构造函数

c++ - OOP构造函数问题C++

c++ - boost 随机数库,对不同的变量生成器使用相同的随机数生成器

java - 为什么默认构造函数和参数化构造函数都在一个类中?

c++ - int f(int *i) 和 int f(int &i) 的区别

c++ - QStringList.indexOf() 没有返回正确的值

c++ - 快速射线和多边形相交

c++ - 如何在不使用 C++0x auto 的情况下实现这种类型特定的对象生成器