Link to home
Start Free TrialLog in
Avatar of gracedman
gracedman

asked on

Method Memory Consumption

I am a little concerned because I have created a class with only a few data members but a very large number of methods to manipulate those members. I anticipate needing a large number of the class objects.
 
 I understand that C++ makes only one copy of the methods for each class while each object has its own copy of the data members. However, is this one copy of the methods shared for each object within a larger object or for all objects in the entire application?
 
 In other words, let's say I have a class which contains a QString object. We'll call this class TestClass. I know that if I have ten QStrings in class TestClass that I will only have one copy of the QString methods and ten copies of the QString data members.
 
 Now let's say that I have created a new class called BigClass. BigClass has five objects of class TestClass. Does BigClass have five copies of the QString methods and 50 copies of the QString data members or one copy of the QString methods and 50 copies of the QString data members? Thanks - John
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial