We help IT Professionals succeed at work.
Get Started

Method Memory Consumption

gracedman asked
Last Modified: 2010-04-01
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
Watch Question
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE