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.
#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;
}
Comments
Leave a comment