I agree with @Hilmar. You can never predict when exactly the object will be destroyed. But, you can definitely predict when an object is ready to be destroyed.
Difference between the two can be easily explained using an example (I'm using JAVA here):
Employee emp = new Employee("Dexter");
This statement creates an object of Employee (with name Dexter) which resides in the heap.
As long as you are using the reference "emp" for this object , the object will stay there. Its indestructible. Garbage Collector cannot even touch it.
Now lets say, after a few lines of code, you are executing:
emp = new Employee("RITA");
This creates a new object of Employee (with name RITA), but notice that the reference "emp" no longer points to our old object with the name Dexter. Hence the object of Employee with the name Dexter has no references associated with it.
And this makes it eligible for the Garbage Collection, and whenever the next round of Garbage Collection happens, the mighty GarbageCollector will not leave this chance to eat up the Employee (with the name Dexter).
The 3 essential concepts of Object Oriented Programming are:InheritanceEncapsulation &Polymorphism
Object-based programming language is a language that supports all the features of object oriented programming features like classes,object,encapsulation ,abstraction,polymorphism etc except inheritence.
The full form of OOP is Object-Oriented Programming.
Just eat a watermellon!
See example code below. #include <iostream> class x { private: // Members. static int counter; int data; public: // Default constructor and destructor. x():data(++counter){printf("Object %d created!\n",data);} ~x(){printf("Object %d destroyed!\n",data);} // other members omitted for brevity... }; // Initialise static counter. int x::counter=0; int main() { // Instantiate an array of 10 objects. x arr[10]; // .. do some work with the array .. return( 0 ); // The array falls from scope, destroying the objects. } Example output: Object 1 created! Object 2 created! Object 3 created! Object 4 created! Object 5 created! Object 6 created! Object 7 created! Object 8 created! Object 9 created! Object 10 created! Object 10 destroyed! Object 9 destroyed! Object 8 destroyed! Object 7 destroyed! Object 6 destroyed! Object 5 destroyed! Object 4 destroyed! Object 3 destroyed! Object 2 destroyed! Object 1 destroyed!
Object to Be Destroyed was created in 1923.
Object Oriented Programming
No, an indestructible object cannot be destroyed or killed.
Yes - 'advanced' PHP programming uses Object Oriented Programming (OOP).
The 3 essential concepts of Object Oriented Programming are:InheritanceEncapsulation &Polymorphism
Object-based programming language is a language that supports all the features of object oriented programming features like classes,object,encapsulation ,abstraction,polymorphism etc except inheritence.
The full form of OOP is Object-Oriented Programming.
Just eat a watermellon!
diff between oops and conventional programming
The purpose of constructor in object oriented programming is to initialize data. Likewise copy constructors are used to initialize an object with data from another object.
In the programming language I am using, the structure of the "ots" keyword is typically used for object-oriented programming and stands for "object to string." It is used to convert an object into a string representation.
See example code below. #include <iostream> class x { private: // Members. static int counter; int data; public: // Default constructor and destructor. x():data(++counter){printf("Object %d created!\n",data);} ~x(){printf("Object %d destroyed!\n",data);} // other members omitted for brevity... }; // Initialise static counter. int x::counter=0; int main() { // Instantiate an array of 10 objects. x arr[10]; // .. do some work with the array .. return( 0 ); // The array falls from scope, destroying the objects. } Example output: Object 1 created! Object 2 created! Object 3 created! Object 4 created! Object 5 created! Object 6 created! Object 7 created! Object 8 created! Object 9 created! Object 10 created! Object 10 destroyed! Object 9 destroyed! Object 8 destroyed! Object 7 destroyed! Object 6 destroyed! Object 5 destroyed! Object 4 destroyed! Object 3 destroyed! Object 2 destroyed! Object 1 destroyed!