Dear Konrad,
  Appreciating for your detailed explanation, it really helps!! Thank you!
I am learning c++ by the means of studying deal.ii, so actually I am a
layman both in deal.ii and c++. I will read the reference page and books
you recommended. Thanks again!!
Best regards,
Yuesu

On Wed, Sep 4, 2019 at 5:03 AM Konrad <ksimon1...@gmail.com> wrote:

> Hi Yuesu,
>
> I think this is rather a general C++ question. Once you create an object
> all members are initialized by invoking a constructor. If you do not
> declare any constructor the compiler will silently generate a set of
> constructors. The default constructor that takes no arguments is one of
> them. This will initialize all members in the order they are given. If you
> have a member of a primitive type like double or int memory for an int or
> double will be reserved (but not initialized with a value yet). If you have
> a class member it also needs to be initialized somehow so the compiler will
> look for a default constructor.
>
> What happens in your example is that the triangulation actually does get
> initialized by invoking its default constructor which initializes an empty
> triangulation. The dof_handler then can be called with the triangulation as
> an argument to store a (smart) pointer to the triangulation.
>
> See this documentation for example:
>
>
> https://docs.microsoft.com/en-us/cpp/cpp/constructors-cpp?view=vs-2019#constructors_in_composite_classes
>
> It is often good to know what the C++ compiler (secretly) does without
> explicitly telling you and what functions it generates if you do not
> provide them explicitly (and when you must do so). I really recommend the
> book by Scott Meyers "Effective C++: 55 ways ..."
>
> Hope that helps.
>
> Best,
> Konrad
>
>
> On Wednesday, September 4, 2019 at 4:44:24 AM UTC+2, yuesu jin wrote:
>>
>> Hi all,
>>
>>   I have a question about the constructor initialization list. In some
>> tutorials, we initialize the dof_handler in the constructor with parameter
>> triangulation, however, the triangulation is initialized in some member
>> function within this class, which means when we initialize the class, we
>> have not had the triangulation yet, I don't know why this method works?
>>
>> Best regards,
>> Yuesu
>>
> --
> 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/fd3807d1-51e6-4daa-8eed-5da2eec1336b%40googlegroups.com
> <https://groups.google.com/d/msgid/dealii/fd3807d1-51e6-4daa-8eed-5da2eec1336b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Yuesu Jin,
Ph.D student,
University of Houston,
College of Natural Sciences and Mathematics,
Department of Earth and Atmospheric Sciences,
Houston, Texas 77204-5008
346-404-2062

-- 
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/CA%2B25a%3DKwsh%2BcjfUv_WTLQ1OW17mC5ASG%3D6w182VRXJ9hHdZL1g%40mail.gmail.com.

Reply via email to