[comp.lang.c++] Order of initialization in a constructor

wallis@labc.enet.dec.com (Barry L. Wallis) (10/04/90)

Is there any way to initialize derived class members before calling the base
class constructor? I understand that the ARM states that, "First, the base
classes are initialized in declaration order (independent of the order of
_mem-initializers_), then the members are initialized in declaration order
(independent of the order of _mem-initializers_)..."

Consider the following simplified code segment:

class Base {
   public:
	  Base(istream sinput, ostream soutput)
	  : input(in), output(out) { /* ... */ }

   private:
	  istream input;
	  ostream output;
}

class Derived : public Base {
   public:
	  Derived(char* inf, char* outf)
	  // This following initialization won't work
	  : infile(inf), outfile(outf), Base(inf, outf) { /* ... */ }

   private:
	  ifstream infile;
	  ofstream outfile;
}

The only way I can see to solve this would be to make a Base object which is a
member of Derived rather than inherit Base. Is there a way around this which
will allow me to use inheritance (like initializing Base in the body of the
constructor)?
---
Barry L. Wallis			USENET: wallis@labc.dec.com
Database Consultant		Prodigy (don't laugh): DNMX41A
U.S. DECtp Resource Center	DECUServe: EISNER::WALLIS (not on the net yet)
Los Angeles, CA			"No one voted for me, I represent myself"
---