P*******b 发帖数: 1001 | 1 Given two classes:
class B
{
public:
B(args_1);
B(args_2);
// and many constructors with different arg lists
};
class D : public B
{
public:
D(args_1) : B(args_1) {}
D(args_2) : B(args_2) {}
// and many constructors with different signatures similarly
implemented
// some additional stuff specific to D
};
Assume that the arg list for B's constructors are quite long and may
be
revised pretty often in the future, in which case D's constructors
have
to be recoded correspondingly. Duplicating the update by
copy-and-paste
will certainly work here. Can you propose a better way so that the
update can be done in one place without copy-and-paste duplication? | d******a 发帖数: 238 | 2 define another class C. using C to construct A and B, and use args_1, args_2
.. to construct C. | q*******p 发帖数: 39 | |
|