mercredi 3 octobre 2018

shared_ptr vs raw ptr

I am coming from C, completely unfamiliar with C++.

From other posts I have read, the gist seems to be: shared pointer allows sharing of "ownership".

My questions are:

  1. what is ownership? Does it merely have to do with garbage collection?
  2. what are other differences between shared_ptr and a raw pointer?
  3. is there a way to convert shared_ptr of a specific type to a generic pointer type? ( the only generic pointer type I know is void*, but I cannot seem to cast shared_ptr to a void* )

Aucun commentaire:

Enregistrer un commentaire