I have a question about calling a constructor in an initialization list of another constructor. For example when looking at code like this:
Library::Child::Child
380 (
381 const word& controlName,
382 const argList& args,
383 const word& systemName,
384 const word& constantName
385 )
386 :
387 Parent
388 (
389 args.rootPath(),
390 args.caseName(),
391 systemName,
392 constantName
394 )
395 {}
with the constructor of class Parent called in line 387:
30 Library::Parent::Parent
31 (
32 const fileName& rootPath,
33 const fileName& caseName,
34 const word& systemName,
35 const word& constantName
36 )
37 :
38 processorCase_(caseName.find("processor") != string::npos), //private member
39 rootPath_(rootPath), //private member
40 case_(caseName), //private member
41 system_(systemName), //private member
42 constant_(constantName) //private member
43 {}
The primary object constructed is of type/class Library::Child::Child, but when constructing that object also the constructor Library::Parent::Parent of parentclass Parent is called and private members of class Parent are defined. Since class Child does not inherit private member of class Parent and furthermore when calling the constructor of class Parent no object/variable is declared (see line 387, first code snippet) I don't know what calling the constructor of Parent is good for? Furthermore in what connection are the private members of class Parent to the class Child object and where are they stored since no class Parent object is declared?
I tried to find information about it in the net, but could not find anything answering my questions.
greetings streight
Library::Child::Childis a derived class from the base classLibrary::Parent::Parent?? (The wordsBaseandDerivedwould make this question considerably easier to follow if that is, in fact, the case). - WhozCraigChildis derived from classParent. I think this is also very easy to understand and in this case accurate sinceChildinherits directly fromParent. Note:Library::Child::Childis the constructor and not the class, but I am sure you know this. - Streight