GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » R3BRoot » General Discussions » Problem with loading TVector3 in R3BRoot (Problem with loading TVector3 in R3BRoot)
Re: Problem with loading TVector3 in R3BRoot [message #23200 is a reply to message #23199] Wed, 31 October 2018 10:21 Go to previous message
Jan Mayer is currently offline  Jan Mayer
Messages: 20
Registered: August 2015
occasional visitor
From: *ikp.uni-koeln.de
I would also like to add the following:

You should not use a pointer for a member that the class owns (= is responsible for), with few exceptions.

Here, R3BTest class can simply own it naturally, like the TString one line above. Just think simple. No need to initialize and delete it, nothing can go wrong, the code is much shorter and easier to understand.

If the class needs to own a polymorphic class, there are unique and shared ptrs.
A class may include pointer members to stuff it is not responsible for.

See also https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-resource
 
Read Message
Read Message
Read Message
Previous Topic: Changes to Detector Constructors for Simulations
Next Topic: Problems with GLAD magnetic field
Goto Forum:
  


Current Time: Fri Mar 29 07:14:20 CET 2024

Total time taken to generate the page: 0.00994 seconds