marc@mit.edu (Marc Horowitz) (05/27/91)
Consider the classes A and B, and the function f: class A { public: A::A(int a, int b, int c, int d); // ... }; class B : public A { public: B::B(char *s) :A(/* ??? */) { ... } // ... }; void f(char *s, int *a, int *b, int *c, int *d) { /* compute a,b,c,d given s */ } Given A and f that I cannot change, is there a way to initialize the A part of B without calling f four times? I was unable to come up with anything which wasn't a disgusting kludge full of static variables. My final decision was that this is a situation for which C++ lacks any construct to do this efficiently. What I really want is the ability to have a block executed in the same scope a static member of B gets initialized at, where I can define variables and do things, then pass these variables on to base class and member constructors, with the block ending after these constructors have all been called. If someone has any really good ideas, please mail me personally, as I do not regularly read this newgroup. Thanks in advance. Marc -- Marc Horowitz <marc@mit.edu>