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: bange...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/d4469b8b-200b-6a30-6ded-7416515cfa23%40colostate.edu.