I'm struggling with Object Oriented Programming.
From a conceptual point view, are instance methods contained in objects (like instance variables are)?
I am picturing objects like this:
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
Conceptually, methods are as much part of an object as the instance variables are. In that way, your view on objects is correct.
However, you should realize that if you have multiple objects of the same type, then physically there will be multiple copies of the instance variables in memory, but only a single copy of the methods. You can view this as an optimization over the conceptual view where the compiler writers found a way to let a single copy of an instance method work with multiple different instances.
It is important to grasp the differences inherent in objects, instances & inheritance.
This depends very much on the language.
Classis a subclass of
Module). Modules are used for mixin inheritance.