From a4b76fba6a9356897724b142e3ff075c0265b74f Mon Sep 17 00:00:00 2001 From: David Wells Date: Thu, 28 Jul 2016 20:13:35 -0400 Subject: [PATCH] Introduce Function better in step-4. --- examples/step-4/doc/tooltip | 2 +- examples/step-4/step-4.cc | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/step-4/doc/tooltip b/examples/step-4/doc/tooltip index 1f94394802..bec9db63be 100644 --- a/examples/step-4/doc/tooltip +++ b/examples/step-4/doc/tooltip @@ -1 +1 @@ -Dimension independent programming. Boundary conditions. +Dimension independent programming. Boundary conditions. Functions. diff --git a/examples/step-4/step-4.cc b/examples/step-4/step-4.cc index cf089844ad..bec2af5372 100644 --- a/examples/step-4/step-4.cc +++ b/examples/step-4/step-4.cc @@ -117,11 +117,19 @@ private: // where we want to evaluate the function. A value for the component can then // simply be omitted for scalar functions. // -// Note that the C++ language forces us to declare and define a constructor to -// the following classes even though they are empty. This is due to the fact -// that the base class has no default constructor (i.e. one without -// arguments), even though it has a constructor which has default values for -// all arguments. +// Function objects are used in lots of places in the library (for example, in +// step-2 we used a ZeroFunction instance as an argument to +// VectorTools::interpolate_boundary_values) and this is the first step where +// we define a new class that inherits from Function. Since we only ever call +// Function::value, we could get away with just a plain function (and this is +// what is done in step-5), but since this is a tutorial we inherit from +// Function for the sake of example. +// +// Unfortunately, some compilers (notably clang 3.8) have a bug where they +// cannot figure out the default constructor (that is, the constructor which +// takes no arguments) of classes derived from Function. For portability we +// provide such constructors in all the tutorial programs so that all +// supported compilers are happy. template class RightHandSide : public Function { -- 2.39.5