Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: std::stack ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 45759 of 47034
Post > Topic >>

Re: std::stack compilation error

by Rahul <sam_cit@[EMAIL PROTECTED] > May 5, 2008 at 08:48 AM

On May 5, 8:32 pm, Christian Hackl <ha...@[EMAIL PROTECTED]
> wrote:
> Rahul wrote:
> > void dfs(struct node * root)
> > {
> >  if(root == NULL) return;
> >  std::stack <struct node *> s;
>
> You don't need the struct keyword here.
>
> >  s.push(root);
>
> >  while(!s.empty())
> >  {
> >   struct node * temp = s.pop();
>
> That's not how std::stack works. top() and pop() are separate
functions:http://www.cppreference.com/cppstack/index.html
>
> >   printf("%d ",temp->data);
> >   s.push(temp->rptr);
> >   s.push(temp->lptr);
> >  }
> > }
>
> > and i get a error saying,
>
> >  ro.c: In function `void dfs(node*)':
> > ro.c:419: `stack' undeclared in namespace `std'
>
> > Am i missing something?
>
> #include <stack> ?
>
> --
> Christian Hackl

Yes, i missed out to include the stack file... Thanks :-)
 




 3 Posts in Topic:
std::stack compilation error
Rahul <sam_cit@[EMAIL   2008-05-05 08:19:16 
Re: std::stack compilation error
Christian Hackl <hacki  2008-05-05 17:32:14 
Re: std::stack compilation error
Rahul <sam_cit@[EMAIL   2008-05-05 08:48:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:07:22 CDT 2008.