Dear Wolfgang,

thanks for clearing this up and responding so fast. Your explanation makes 
sense to me.

Best
Konrad

Wolfgang Bangerth schrieb am Mittwoch, 8. März 2023 um 15:03:13 UTC+1:

> 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/
>
>
>

-- 
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/8a6d8887-dd98-4945-9325-f51731f10e3dn%40googlegroups.com.

Reply via email to