Will class member functions consume memory storage?

Apr 5, 2015 at 11:54am
For example:

1
2
3
4
5
6
7
class a {
public:
    int v;//this one will need memory to store

    int method1();//how about these?
    int method2();
    ......


Thanks.
Apr 5, 2015 at 12:35pm
Question is quite undefined.
A function itself will occupy just the space for its activation record from the caller, for parameters and for its local variables on the stack. According to architecture the activation record will contain things like saved registers, address to return when the function is called and whatever.

But a function can allocate how much memory it requires on the heap so there is no a precise answer.

Oh in addition, if the function is recursive then it could use a lot of memory, always because of activation records which are needed between each call.
Apr 5, 2015 at 1:37pm
thanks!
Topic archived. No new replies allowed.