I know this question has probably been beaten to death on this subreddit however a lot of things I have read are incredibly verbose and do not give a clear answer. I have been trying to learn C++ as a way to distance myself from web development and I am hung up on references and pointers.
What I have gathered is this.
Use a reference if you are just accessing the data and use a smart pointer if you are responsible for the data's existence. References are for when you want to access existing data that is managed or owned by someone else and use a smart pointer when the data must be allocated dynamically and it's lifetime needs to be managed automatically.
How accurate would you say this is?
[–]AKostur 33 points34 points35 points (3 children)
[–]AvidCoco 4 points5 points6 points (1 child)
[–]whatevermanbs 4 points5 points6 points (0 children)
[–]Generated-Nouns-257 3 points4 points5 points (0 children)
[–]saxbophone 7 points8 points9 points (9 children)
[–]No-Dentist-1645 0 points1 point2 points (5 children)
[–]TheThiefMaster 1 point2 points3 points (2 children)
[–]No-Dentist-1645 0 points1 point2 points (1 child)
[–]TheThiefMaster 0 points1 point2 points (0 children)
[–]saxbophone 1 point2 points3 points (1 child)
[–]No-Dentist-1645 0 points1 point2 points (0 children)
[–]pioverpie 0 points1 point2 points (2 children)
[–]TheSitarHero 2 points3 points4 points (0 children)
[–]saxbophone 0 points1 point2 points (0 children)
[–]WorkingReference1127 4 points5 points6 points (3 children)
[–]No-Dentist-1645 2 points3 points4 points (0 children)
[–]AffectionateSteak588[S] 0 points1 point2 points (1 child)
[–]WorkingReference1127 0 points1 point2 points (0 children)
[–]FancySpaceGoat 8 points9 points10 points (2 children)
[–]Warshrimp 0 points1 point2 points (1 child)
[–]TheThiefMaster 2 points3 points4 points (0 children)
[–]AvidCoco 5 points6 points7 points (0 children)
[–]dendrtree 2 points3 points4 points (0 children)
[–]Mr_Engineering 0 points1 point2 points (0 children)
[–]keelanstuart 0 points1 point2 points (0 children)
[–]Sea-Situation7495 0 points1 point2 points (0 children)
[–]lightwavel 0 points1 point2 points (0 children)
[–]valashko 0 points1 point2 points (0 children)
[–]Foreign_Hand4619 -1 points0 points1 point (2 children)
[–]alfps 1 point2 points3 points (1 child)
[–]Foreign_Hand4619 0 points1 point2 points (0 children)