Answer to Question #261249 in C++ for zain

Question #261249

1.      Create a class Node with

a.      attributes data and next pointer

b.      accessors and mutators

c.      constructor and destructor

d.     function called display

e.      search node returning true or false

f.       overload the function search to include lookAhead method.

1
Expert's answer
2021-11-05T00:33:25-0400


#include <iostream>


using namespace std;


class Node{
  int data;
  Node *next;
  
  public:
    void setData(int d){
        data=d;
        
    }
    int getData(){
        return data;
    }
    Node(){
        
    }
    ~Node(){
        
    }
    void display(){
        cout<<"\nData = "<<data;
    }
    bool searchNode(){
        return true;
    }
    bool searchNode(int n){
        return true;
    }
};
int main()
{
    Node d;
    d.setData(35);
    d.display();


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS