Help in value_list

31 views
Skip to first unread message

Atanu Banerjee

unread,
Nov 3, 2016, 11:08:24 AM11/3/16
to deal.II User Group

Hi,

This may be a trivial issue, but as a beginner in c++, I am unable to to understand the following. Someone please explain.
In step-7, there is no member function named "value_list" is defined for the "right_hand_side" object. Then how is it used in the assemble_system.

Thanks
Atanu

Jean-Paul Pelteret

unread,
Nov 3, 2016, 11:27:52 AM11/3/16
to deal.II User Group
Dear Atanu,

The RightHandSide class in step-7 derives from the Function class. This in turn defines the value_list function that, according to the documentation, calls the value function. Since this function is marked as virtual, when the base class calls the value() function, the derived class' definition (i.e. what is defined in the RightHandSide class) is invoked.

I hope that this helps to explain what's going on here.

Regards,
J-P

Atanu Banerjee

unread,
Nov 3, 2016, 11:54:39 AM11/3/16
to deal.II User Group
Ok... Thank you Jean.

Jean-Paul Pelteret

unread,
Nov 3, 2016, 12:12:23 PM11/3/16
to deal.II User Group
You're welcome. Since you say that you're a C++ beginner, I'm not sure how much you know about polymorphism: just in case you need some further clarification, here's an example that highlights what's actually going on here with the base and derived classes (namely virtual function overloading).

On Thursday, November 3, 2016 at 4:54:39 PM UTC+1, Atanu Banerjee wrote:
Ok... Thank you Jean.

Atanu Banerjee

unread,
Nov 4, 2016, 12:22:20 AM11/4/16
to deal.II User Group
Thanks a lot for the reference. I got the point. Please help in one more thing.
While defining the virtual member functions, e.g., RightHandSide::value, at the end of the function declaration "const" is added. Why is it so? Can you please give a reference?

Thanks
Atanu

Jean-Paul Pelteret

unread,
Nov 4, 2016, 3:46:03 AM11/4/16
to deal.II User Group
Dear Atanu,

Here are two stackoverflow posts (the first one more technical, the second by example) that provide a satisfactory answer to your second question. The search term I used in google to find these posts was

c++ function const at the end

Regards,
J-P
Reply all
Reply to author
Forward
0 new messages