inheritance - Is it possible to call the constructor of a super class, two classes away from the current class in C++ -
i have 3 classes inherit follows:
class_a class_b : public class_a class_c : public class_b
class_a
contains constructor:
public: class_a(const char *name, int kind);
class_b
not contain constructor.
in class_c
wish invoke constructor of class_a. like:
class_c(const char *name, int kind) : class_a::class_a(name,kind) {
}
the problem cannot add intermediate constructor class_b
, because class_b
generated code regenerates every time make clean. cannot make lasting changes class_b
. needless say, above line of constructor in class_c
gives error: "type 'class_a' not direct base of '
class_c'".
is there way may invoke constructor of class_a
in subclass class_c
, without requiring same type of constructor in class_b
?
if can't change code generates b
, out of luck, afaik. if a
class contains such constructor, maybe can away adding simple member function sets 2 variables , call inside c
constructor? may not efficient gets, atleast works.
Comments
Post a Comment