0

Where are member functions of object present ?and how they access objects if they are common for each object and present in text

actually I want to ask that if member function do not take memory for different objects of same class then where these member functions are situated and are they created before creating the object of that class or after creating the object and how member functions of the class able to access different object of that class and work for them

4th Aug 2018, 3:05 AM
Prateek Chaturvedi
Prateek Chaturvedi - avatar
3 ответов
+ 1
Prateek Chaturvedi sorry but I am not able to get your question... Whatever I got from your question, below is my answer... correct me if I misunderstood.. If you have class A and member int a, you don't have memory associated with int a... Now, if you create object with A obj1 and A obj2, two int memory will be allocated and both int of obj1 and obj2 can have different values if you make int a as static in class, you are making it as common for each object and only one memory location of int will be allocated irrespective of any number of objects. Once you make static variable, it's common practice to access the same with class name instead of object.variablename, but you can still access it with object as well
4th Aug 2018, 4:07 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
well I am taking about member functions not data members(variables)
4th Aug 2018, 5:19 AM
Prateek Chaturvedi
Prateek Chaturvedi - avatar
0
I responded just now to your other thread for functions: https://www.sololearn.com/Discuss/1437199/?ref=app feel free to ask if you have any doubt... Happy to help
4th Aug 2018, 12:01 PM
Ketan Lalcheta
Ketan Lalcheta - avatar