|
[Sponsors] |
member function [value()] of dimensioned<Type> class |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 8, 2010, 02:02 |
member function [value()] of dimensioned<Type> class
|
#1 |
New Member
Sang Bong Lee
Join Date: Nov 2009
Posts: 5
Rep Power: 17 |
I tried to understand the code of OpenFOAM, specifically simplefoam, but I met a small obstacle in the usage of value() function which is a memeber function of dimensioned<Type> class.
In the constructor of Time class, setControls() is executed and setControls calls the function of setTime(starTime_, 0). In the function of setTime, value()=newTime is not clear. Let me take a similar example. #include <iostream> using namespace std; template<class Type> class dimensioned { Type value_; public: Type& value() { return value_;} }; int main() { int Rvalue=1; dimensioned<int> myType; myType.value()=Rvalue; return 0; } In the above examle, the member function of value() cannot be used without class name. But in the function of setTime it was called without class name. I am looking forward to your kind reply because I am a beginner of C++. |
|
November 9, 2010, 03:57 |
|
#2 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18 |
Hi,
I think value() can be used in this way, because it is a member of the class itself, even it is not defined in Time explicitly. But this class seems to be somehow derived form dimensionedType and therefore it is known. It just the same as setControls() is used. (without object because it should work on object itself). Regards, Stefan |
|
November 9, 2010, 04:52 |
Re_questions
|
#3 | |
New Member
Sang Bong Lee
Join Date: Nov 2009
Posts: 5
Rep Power: 17 |
Quote:
My limited knowledge of C++ does not makes me fully understand your reply yet. It is clear that both setControls() and setTime() are used without instance because they are defined inside Time class. But value() is defined in dimensioned<Type> class (not in Time class), so I think that value() could be called in Time class with instance as following dimensioned<scalar> myType; myType.value(); Thank you for your reply in advance... Last edited by sblee1977; November 9, 2010 at 20:31. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compile problem | ivanyao | OpenFOAM Running, Solving & CFD | 1 | October 12, 2012 10:31 |
latest OpenFOAM-1.6.x from git failed to compile | phsieh2005 | OpenFOAM Bugs | 25 | February 9, 2010 05:37 |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 11:23 |
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug | unoder | OpenFOAM Installation | 11 | January 30, 2008 21:30 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 15:00 |