CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

function objects and virtual inheritance

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 6, 2011, 05:17
Default function objects and virtual inheritance
  #1
New Member
 
Michael Buchmayr
Join Date: Mar 2010
Posts: 16
Rep Power: 16
MichiB is on a distinguished road
Hello Friends!

I'm having a little programming problem here, so hopefully one of you C++ experts can help me out of it!

I have programmed multiple function objects, using three 3 levels of inheritance.
1st) BaseLevel 2nd) MethodsLevel 3) CustomizedMethods- and OutputLevel

In order to overcome the diamond problem, I introduced virtual inheritances (e.g. class B :: virtual public A).

This however causes the following compilation error message:

/graz/home/openfoam/OpenFOAM/OpenFOAM-1.5-dev/src/sampling/lnInclude/IOOutputFilter.C: In constructor ‘Foam::IOOutputFilter<OutputFilter>::IOOutputFilte r(const Foam::word&, const Foam:bjectRegistry&, const Foam::fileName&, Foam::IOobject::readOption, bool) [with OutputFilter = Foam::TurboPressure]’:
/graz/home/openfoam/OpenFOAM/OpenFOAM-1.5-dev/src/sampling/lnInclude/OutputFilterFunctionObject.C:78: instantiated from ‘bool Foam::OutputFilterFunctionObject<OutputFilter>::st art() [with OutputFilter = Foam::TurboPressure]’
HierarchyLevel2/TurboPressure/TurboPressureFunctionObject.C:41: instantiated from here
/graz/home/openfoam/OpenFOAM/OpenFOAM-1.5-dev/src/sampling/lnInclude/IOOutputFilter.C:53: error: no matching function for call to ‘Foam::TurboBase::TurboBase()’
lnInclude/TurboBase.H:157: note: candidates are: Foam::TurboBase::TurboBase(const Foam::word&, const Foam:bjectRegistry&, const Foam::dictionary&, bool)
lnInclude/TurboBase.H:113: note: Foam::TurboBase::TurboBase(const Foam::TurboBase&)
make: *** [Make/linux64GccDPOpt/TurboPressureFunctionObject.o] Error 1


Apparently I'm calling the constructor Foam::TurboBase::TurboBase() on line 53 of file IOOutputFilter.C.
I don't know why the line's actual constructor Foam::TurboBase::TurboBase(const Foam::word&, const Foam:bjectRegistry&, const Foam::dictionary&, bool) is not called, but it certainly has to do with the virtual inheritance declaration.

Any hints ????
MichiB is offline   Reply With Quote

Old   September 15, 2015, 19:29
Default
  #2
New Member
 
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 26
Rep Power: 16
vitor.geraldes@ist.utl.pt is on a distinguished road
OpenFOAM is a great tool, but unfortunately we need sometimes to go inside the dark forest of multiple inheritance to get the job done! I tell this after seeing your old post and the following quotation
"...In object-oriented programming, Inheritance is the evil forest. Experienced programmers know to avoid this evil because they know that deep inside the Dark Forest Inheritance is the Evil Queen Multiple Inheritance. She likes to eat software and programmers with her massive complexity teeth, chewing on the flesh of the fallen. But the forest is so powerful and so tempting that nearly every programmer has to go into it, and try to make it out alive with the Evil Queen's head before they can call themselves real programmers. You just can't resist the Inheritance Forest's pull, so you go in. After the adventure you learn to just stay out of that stupid forest and bring an army if you are ever forced to go in again."(http://learnpythonthehardway.org/book/ex44.html)
vitor.geraldes@ist.utl.pt is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:26.