auto_ptr & lists

Hi all,
I was trying to use auto pointers in a list with the following code fragment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Node {
public:
    int i;
    auto_ptr<Node> pnode;

};

int main(){
    auto_ptr<Node> p1 (new Node);
    (*p1).i=1;

    auto_ptr<Node> p2 (new Node);
    p1->pnode=p2;
}



When I try to replace the lines:
1
2
    auto_ptr<Node> p2 (new Node);
    p1->pnode=p2;


by
 
p1->pnode (new Node);

I get the following error

no match for call to ‘(std::auto_ptr<Node>) (Node*)

How should I implement the line in order to avoid the error?

thank in advance
santiagorf


Try p1->pnode.reset(new Node);
thanks, that worked!!
Topic archived. No new replies allowed.