|
[Sponsors] |
July 30, 2020, 11:29 |
Inheritance in DynamicList<Type>
|
#1 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 352
Rep Power: 11 |
Howdy Foamers:
I am scratching my head on this. I am using a DynamicList in my solver implementation. According to the OpenFOAM API, DynamicList is inherited from List, which is in turn inherited from UList. List has a public member append(), while UList has a public member find(). In theory both should be accessible from my instance of DynamicList. However, while calling DynamicList::append() compiled without problem, the compiler complained about DynamicList not being to access find(). This behavior is consistent with all member functions in List (no errors) and UList (compiler errors). This leads me to believe this could be an issue with my understanding with the C++ language. I am wondering if I am missing something, and how could I access the find function from DynamicList? Thanks in advance, Gerry. |
|
July 30, 2020, 13:03 |
|
#2 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 352
Rep Power: 11 |
A few notes, kinda strange:
1) find () is not in UList in the distribution I am using (OF 7), while it is according to the 2006 API. Strange, but I guess my assumption is wrong, where the implementation for the very basic classes are supposedly identical between .org and .com. 2) Looks like you do need to refer to the base class when calling one of its member functions, i.e., myDynamicList.UList::find(), assuming the member find() is here. Gerry. |
|
July 31, 2020, 10:03 |
|
#3 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 352
Rep Power: 11 |
Okay, i ended up implementing the find member function in the .org flavor of UList. I am still scratching my head as to why the basic data structure are differently implemented.
|
|
July 31, 2020, 10:19 |
|
#4 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15 |
FOAM was conceived in a time where STL wasnt as mature, so many basic containers were implemented directly as to avoid library performance issues. An example is the autoPtr<> handle, which in some forks of FOAM is beibg slowly converted to std::auto_ptr.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple inheritance paradigms in OpenFOAM | raumpolizei | OpenFOAM Programming & Development | 3 | January 4, 2019 08:16 |
function objects and virtual inheritance | MichiB | OpenFOAM Programming & Development | 1 | September 15, 2015 19:29 |
Virtual inheritance problem while adding public member function to LES SGS Model | konneym | OpenFOAM Programming & Development | 4 | November 4, 2013 11:37 |
inheritance and collaboration diagrams, | hawkeye321 | OpenFOAM | 1 | March 2, 2013 06:06 |
Multiple inheritance, function pointers or? | ngj | OpenFOAM | 0 | March 20, 2009 10:36 |