lundi 23 décembre 2019

How can i handle shared_ptr ++

 int main ()
 {
    shared_ptr<int[]> a(new int[2]);

    a.get()[0] = 5;
    a.get()[1] = 10;

    int* foo = a.get();

    ++foo;

    cout << *foo << endl;

    return 0;
}

The output is "10" as i expected. But I used regular pointer (int* foo) how can i implement/use ++ operator with only shared_ptr.

Aucun commentaire:

Enregistrer un commentaire