Skip to main content
Sardar Badar Saghir's user avatar
Sardar Badar Saghir's user avatar
Sardar Badar Saghir's user avatar
Sardar Badar Saghir
  • Member for 4 years, 5 months
  • Last seen more than 1 year ago
Stats
1
reputation
1k
reached
0
answers
3
questions
About

I am Passionate developer and esthetic keen for learning new technologies. I am Familial with technologies like unity, java, python, c, c++, dart, flutter, linux, and cyber-security. I am fascinated by the technologies and now looking forward to learn them.

    #include <iostream>

using namespace std;

//CODE FOR SELF CREATING STRUCTURE
struct Node{
    int id;
    Node *prev;
    Node *next;
    int data;
    
};

/******************************************************************************/
//CREATING CLASS OR FINGER PRINT OF OBJECT
 class ListCircularDouble{

    public:
        
//CREATING GOLBAL POINTER FOR OBJECT;
        
     Node *start, *previous, *node;
     
//ID FOR CREATING ARRAY LIKE BEHAVIOR
     int id=0;
     
 //SOME IMPORT INITIALIZTION WHILE CALLING CONSTRUCTOR   
     ListCircularDouble(int data){
      
          node=new Node;
          start=node;
         previous=node;
         
         previous->prev=node;
         previous->next=node;
         node->data=data;
         start->id=id;
        
         cout<<"id Number "<<id<<"="<<data<<endl;

        
     }
     
         
//ADD ELEMENT IN START
    void addAtStart(int data){
       cout<<"id Number "<<id+1<<"="<<data<<endl;
        id=id+1;
        cout<<id<<endl;
         node=new Node;
         node->data=data;
         node->id=id;
         previous->next=node;
         node->prev= previous;
         start->prev=node;
         node->next=start;
         previous=node;
           
         
        
    };
    
 
 //DISPLAY LIST   
    void display(){
        Node *ptr=start;
       do { 
           
        cout<<ptr->id<<"-> "<<ptr->data<<",  ";          
        ptr=ptr->next;
               
            
        }  while(ptr!=start);
        cout<<endl;
        
    };    
 
         
     
    
 //ADD MULTIPLE ELEMENT WHERE N IS NUMBER OF ELEMENT  
  void createListInt(int n){
       
        cout<< "Add "<<n<<" Elements"<<endl;
        int data;
        
        for ( int i = 0; i < n; i ++ ) {
            cin>>data;
           this->addAtEnd (data);
           
        }     
    };


   
      
    
};




int main(){
    
    //Create At least 1 element By creating OBj
ListCircularDouble list1(2);

//ADD ELEMNTS
list1.addAtStatt (20);
list1.addAtStart (30);
list1.display();

       
}
Badges
This user doesn’t have any gold badges yet.
This user doesn’t have any silver badges yet.
2
bronze badges
0
Score
1
Posts
33
Posts %
0
Score
1
Posts
33
Posts %
0
Score
1
Posts
33
Posts %
0
Score
1
Posts
33
Posts %
0
Score
1
Posts
33
Posts %
0
Score
1
Posts
33
Posts %
Top posts