I am preparing for an exam, and I am being told there will be, "1 multiple-choice question about reading a piece of code about objects interacting with functions and deciding the output."
There are a few ways I can think of:
- Passing an object into a function as an argument
- An object calling a function with a dot operator
- Creating a new object through a Constructor and Class(Does that count?)
Are there other ways that objects interact with functions that I am not thinking of?
Objects can take function pointers as a method or constructor parameters, store them, return them, call them! (google: callback)
Another thing they could do on old machines but requires some non-trivial messing with low-level stuff to take off execution protection flag from memory page: dynamically create new functions!