On 3/8/23 06:34, Konrad Schneider wrote:
>
> Only if I uncomment line 30 of my code (// , mapping(mapping_degree)) the
> program compiles. Why is that? In my understanding, the program should compile
> just fine without the initialization of the mapping member variable since
> there is no requirement of initializing member variables upon constructing an
> object, is would be the case for my member variable unsigned int test.
This isn't true. In a constructor, *all* member variables [1] are initialized
by calling their constructors. If you explicitly list a member in the
initializer list (after the ':'), then the constructor arguments so specified
are taken. If you don't explicitly list a variable, then the default
constructor of the variable's class is called. But the latter only works if
the class *has* a default constructor. It turns out that MappingQ does not:
The only constructor there is requires you to provide the polynomial degree.
As a consequence, the compiler cannot do a default-initialization, and you are
forced to explicitly list the variable in the initializer list.
Best
W.
[1] This is not quite true: all *class type* member variables are initialized,
whereas variables of built-in types like int, double, etc are not unless you
explicitly initialize them.
--
------------------------------------------------------------------------
Wolfgang Bangerth email:
bang...@colostate.edu
www:
http://www.math.colostate.edu/~bangerth/