What is Destructor ?

No comments

Destructor :-

Destructor is a member function having the character ~(Tiled Symbol) followed by the function name which is same as the class name and automatically executed when the object is no longer needed.

Example :-  class student
                                      {
                                        private:
                                         int roll;
                                        public:
                                         student ()
                                                      {
                                                            Cout << “object is created”;
                                                       }
                                                           ~ student()
                                                             {
                                                                     Cout << “object is killed”;
                                                                }
                                     };
Output :   object is created
                    object is killed

No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀