HI
I am trying to combine(I think that is the word) a node and a class together.Could anybvody try to find the error I have thx

#include<iostream>
#include<conio.h>
using namespace std;
struct Node
{
  int data;
  Node* link;
};
typedef Node* NodePtr;
class Q
{
  public:
         void insert_data(int data);
         void display_data(int another_data);
  private:
          Node* head;
};
int main()
{
  NodePtr q;
  int number;
  cout<<"What is the number you would like to use: ";
  cin>>number;
  q.insert_data(number);
  q.display_data(number);
  
  getch();
  return 0;
}
void Q::insert_data(int data)
{
 cout<<"What number ould you like to use: ";
 head=new Node;
 cin>>head->data;
 head->link=NULL;
}
void Q::display_data(int another_data)
{
 cout<<head->data;
}

the problem is in line 28 that is:
28 C:\Documents and Settings\mauro\Desktop\c++\nodes - combine with class.cpp `insert_data' has not been declared

NodePtr q;

That's the wrong type. I think you meant to declare an object of Q instead of a NodePtr...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.