Skip to content
Snippets Groups Projects

Add exercise about smart pointers.

Merged Stephan Hageboeck requested to merge shageboe/cpluspluscourse:smartPtr into master
1 unresolved thread

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Very nice ! Thanks a lot. For me it's ready to merge, only you may want to add few lines into my new Cheat sheet : https://gitlab.cern.ch/sponce/cpluspluscourse/-/blob/master/code/ExercisesCheatSheet.md. I can also merge right now and add it later.

  • Sebastien Ponce mentioned in commit 2314625b

    mentioned in commit 2314625b

  • @shageboe I've merged and integrated it into the slides and CheatSheet. I've also solved the exercises myself just to check everything was fine. Great job ! Very nicely done.

    I have only 2 comments if you're interested :

    • in problem 2, I had solved it in a slightly different way, being more lazy and changing less code :-) I did not replace the new (ok, I did not follow the instructions, true) and just declared a vector of unique_ptr and used emplce_back instead of push_back when filling it.
    • problem 4 is actually very similar to the memcheck exercise. The flow is the same and I solved it by simply adding one virtual keyword for the base constructor. Thus I wonder whether its place is really in the smartPointer exercise. Now solving twice the same problem is a nice way to be sure you remember it, so we should probably still keep it.
    • Hi @sponce,

      I did not replace the new (ok, I did not follow the instructions, true) and just declared a vector of unique_ptr and used emplce_back instead of push_back when filling it.

      That's fair :-). I still wanted to somehow convey that it's a good idea to return unique_ptr instead of raw ptr in a factory. Any ideas how to change it a bit so people learn this?

      problem 4 is actually very similar to the memcheck exercise. The flow is the same and I solved it by simply adding one virtual keyword for the base constructor. Thus I wonder whether its place is really in the smartPointer exercise. Now solving twice the same problem is a nice way to be sure you remember it, so we should probably still keep it.

      I hadn't seen that. I'll have a look whether I can change it. It's not about inheritance, it's about smart ptrs!

    • On first point, just leave it like this. Your solution is better than mine I believe, it was just to mention that we will probably also encounter mine when tutoring

      On the second point, what was the smart ptr precise point you wanted to demonstrate in this one that was not in the previous problems ?

    • I had an idea, and I'm already on it. I may be done before the afternoon sessions.

    • Done, see !14 (merged)

    • Please register or sign in to reply
Please register or sign in to reply
Loading