Memory taken by member functions of a class

As per my knowledge functions by themselves don’t take up any memory, it is only when a function is called that all its local variables are assigned memory.

But towards the end of the getters and setters lecture, the instructor claimed that all the member functions reside in the same memory and don’t get duplicated for every instance of the class.

Also in one of the previous lectures it was said that classes by themselves don’t take up any memory.

All these things clearly contradict each other,
so… which of these are true ?

@Naman-Bansal-2736674666374052
First thing is we are talking about the member functions that are inside a class not simple functions.

Functions are mostly machine code, starting at some specific address. The start address is all that is needed to call the function.
So objects need at most the address of called functions.
But an object won’t need extra space for that function.

So whenever a function is called then it create the local variables based upon the object which is calling.

I hope this clears your doubt

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.