]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add constructors to classes, where C++ requires us to do so.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Jul 2001 07:52:02 +0000 (07:52 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Jul 2001 07:52:02 +0000 (07:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@4817 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-4/step-4.cc
deal.II/examples/step-5/step-5.cc
deal.II/examples/step-6/step-6.cc
deal.II/examples/step-7/step-7.cc

index 893a55f47713a84954bff0e734ffd7efb263d989..1998d4dfc2dba6e01a444201997dedcdecf3a5c5 100644 (file)
@@ -124,10 +124,23 @@ class LaplaceProblem
                                 // side with only one parameter,
                                 // namely the point where we want to
                                 // evaluate the function.
+                                //
+                                // 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.
 template <int dim>
 class RightHandSide : public Function<dim> 
 {
   public:
+    RightHandSide () : Function<dim>() {};
+    
     virtual double value (const Point<dim>   &p,
                          const unsigned int  component = 0) const;
 };
@@ -138,6 +151,8 @@ template <int dim>
 class BoundaryValues : public Function<dim> 
 {
   public:
+    BoundaryValues () : Function<dim>() {};
+    
     virtual double value (const Point<dim>   &p,
                          const unsigned int  component = 0) const;
 };
index 4ebba492a33224d8f3be7f0e81621d3580565505..dbe1414ac98b91d187bad5f38b90e142f5706476 100644 (file)
@@ -98,10 +98,17 @@ class LaplaceProblem
                                 // information from the ``value''
                                 // function as well will be explained
                                 // below when assembling the matrix.
+                                //
+                                // The need to declare a seemingly
+                                // useless default constructor exists
+                                // here just as in the previous
+                                // example.
 template <int dim>
 class Coefficient : public Function<dim> 
 {
   public:
+    Coefficient ()  : Function<dim>() {};
+    
     virtual double value (const Point<dim>   &p,
                          const unsigned int  component = 0) const;
     
index c0e2ede8cd12c7cdd4ffa0b4a6ba8ed85adc1d82..71bbe914e6d2c035214b841dddb4d6732686dd10 100644 (file)
@@ -140,6 +140,8 @@ template <int dim>
 class Coefficient : public Function<dim> 
 {
   public:
+    Coefficient () : Function<dim>() {};
+    
     virtual double value (const Point<dim>   &p,
                          const unsigned int  component = 0) const;
     
index c8bbcc6337e7edf028063676faaf6d25767b86fa..0f13486717af7d64829f009b3d85ef9ac6427041 100644 (file)
@@ -180,11 +180,19 @@ const double SolutionBase<dim>::width = 1./3.;
                                 // respective virtual member
                                 // functions in the ``Function'' base
                                 // class.
+                                //
+                                // Just as in previous examples, we
+                                // are forced by the C++ language
+                                // specification to declare a
+                                // seemingly useless default
+                                // constructor.
 template <int dim>
 class Solution : public Function<dim>,
                 protected SolutionBase<dim>
 {
   public:
+    Solution () : Function<dim>() {};
+    
     virtual double value (const Point<dim>   &p,
                          const unsigned int  component = 0) const;
     virtual Tensor<1,dim> gradient (const Point<dim>   &p,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.