Skip to content

Instantly share code, notes, and snippets.

@gcs-abdulwahab
Created July 26, 2022 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcs-abdulwahab/525a1b9ee9574d607830c7ed95f19a7f to your computer and use it in GitHub Desktop.
Save gcs-abdulwahab/525a1b9ee9574d607830c7ed95f19a7f to your computer and use it in GitHub Desktop.
My Description to DSA class for Node Class
// 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;
}
@gcs-abdulwahab
Copy link
Author

Anyone can comment over here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment