简体   繁体   中英

Convert from raw pointers to smart pointers

I want to use smart pointers instead of raw pointers. How can I convert this function accordingly?

Node * List::next(const Node * n) const {
    return n->next;
}

Like this:

Node * List::next(const Node * n) const {
    return n->next;
}

As far as I can tell the function next doesn't not perform any transfer of ownership so it doesn't need to concern itself with means of ownership of Node objects so it doesn't need to change. (It doesn't need to be a member of List or it could be a static member.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM