Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!decwrl!deccrl!bloom-beacon!bloom-picayune.mit.edu!news.mit.edu!marc From: marc@mit.edu (Marc Horowitz) Newsgroups: comp.lang.c++ Subject: computed arguments to base class constructors Message-ID: Date: 26 May 91 22:15:20 GMT Sender: news@athena.mit.edu (News system) Distribution: comp Organization: mit sipb Lines: 38 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