Crash course Object Oriented Programming: A class describes a type, like “Dog” or “Person”. An object is an instance of that type, like “Fido” is an object of type “Dog”. A method is a function defined as part of the class, and called on an object. For example, “feed()” might be method of “Dog” and you can then call “Fido.feed()” to feed Fido the Dog.
Ok, with that knowledge, we can now explain that a constructor is a special method which is called whenever a new object is created.
The intended purpose of the constructor is that it sets up all the internal data of the object, but you can do whatever you want with it.
Latest Answers