Created
July 26, 2022 06:07
-
-
Save gcs-abdulwahab/525a1b9ee9574d607830c7ed95f19a7f to your computer and use it in GitHub Desktop.
My Description to DSA class for Node Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Abdul-Wahab GCS-s22-003 | |
#include <iostream> | |
using namespace std; | |
class Node { | |
private: | |
int data; | |
Node* next; | |
public: | |
Node(int data , Node* next=NULL){ | |
setData(data); | |
setNext(next); | |
} | |
void setData(int data){ | |
this->data = data; | |
} | |
int getData(){ | |
return this->data; | |
} | |
void setNext( Node* next){ | |
this->next = next; | |
} | |
Node* getNext(){ | |
return next; | |
} | |
}; | |
int main() { | |
Node n1(2); | |
Node n2 (3); | |
n1.setNext(&n2); | |
cout<<n1.getData()<<endl; | |
cout<<n2.getData()<<endl; | |
cout<<"n1 getNext "<< n1.getNext()<<endl; | |
cout<<"n2 address "<< &n2<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anyone can comment over here