Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8698097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:40:03+00:00 2026-06-13T01:40:03+00:00

I am getting this message with everything that has Node* (this declaration has no

  • 0

I am getting this message with everything that has Node* (this declaration has no storage or type specifier). Could somebody help and please send me in the right direction?

template <typename type>
Node* Stack<type>::pop() {
Node* retNode; // the node to be return
if(tos == NULL) {
    cerr << "*** Stack empty ***";
    exit(1);
}
else {
    retNode = tos; // store the location of tos
    tos = tos->getLink(); // move to new tos
    retNode->setLink(); // unlink the popped node from the stack
    size -= 1;
}
return retNode;
}

I am sure it’s dealing with Node* but I just can’t figure out what.

Below are my declarations for the node class that are being used in my stack class. Let me know if you need my declarations for the stack class as well because I just cant see the problem.

template <typename type>
class Node<type>{

private:
type data;
Node *link;

public:
Node(type p_item, Node *p_link);
type getData() const;
Node* getLink() const;
void setData(type p_data);
void setLink(Node *node);
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:40:03+00:00Added an answer on June 13, 2026 at 1:40 am

    Node is a class template, so you cannot use Node or Node * as data types. You must add template arguments in angle brackets, e.g. Node<int> or Node<char> * etc.

    In the specific example you gave, it seems the following would be appropriate:

    template <typename type>
    Node<type>* Stack<type>::pop() {
      Node<type>* retNode;
      /* ... */
      return retNode;
    }
    

    I.e. the same type argument that is used for Stack should (probably) be used for Node as well.

    Two further notes:

    1. It seems odd that, while the Node template appears to implement internal data structures of your stack, Node<type> * pointers are returned by the pop function of the stack. It would seem more natural (and better encapsulation, and more intuitive for the users of your stack) to return type objects.

    2. It also seems odd that the pop function calls exit (and thus brings the entire process to a halt) when the stack is empty. Perhaps returning nullptr, or a dummy object, or throwing an exception (or a similar strategy) would be more appropriate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
I'm getting this message (on the log) when trying to start a SSAS Tabular
I am abviously missing something, but I keep getting this message when trying to
Am getting this error message and matched my brackets and couldn't find anything wrong.
I'm getting this error message whiile running a Webservice I'm working on. it builds,
I'm getting this error message with the code below: class Money { public: Money(float
I'm getting this strange error message when trying to clone or pull from git.
I'm getting hundreds of this message in the console: __NSAutoreleaseNoPool(): Object 0x5d86f30 of class
This is the actual error message i'm getting if i run it on an
A buddy of mine has been getting this error mesage when trying to run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.