Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:46:59+00:00 2026-06-17T08:46:59+00:00

Possible Duplicate: Why class size, depends only on data members and not on member

  • 0

Possible Duplicate:
Why class size, depends only on data members and not on member functions?

When I first learnt about Inheritance, my teacher remarked that as opposed to data members, member function don’t change the class size. That is, if class B inherits from class A then B’s size will be larger than A’s size if and only if at least one data member will be added, and won’t be changed with respect to function members quantity.
Is it correct? If so, How this mechanism works? It seems like both members should be held in the heap and therefore will cost in size.

Thank you,
Guy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:47:00+00:00Added an answer on June 17, 2026 at 8:47 am

    Member variables are stored as part of each class instance. But member functions are not.

    Each instance of a class must have a separate copy of each member variable. This keeps each object unique.

    But member functions are code. And no matter how many instances you have of a particular class, there is absolutely no reason to have multiple copies of the code. The same code simply operates on the instance data.

    Since code is different, code is not part of the size of a class instance. And sizeof(myClass) will not include bytes occupied by code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Wrapper class in java I learnt about wrapper class that it is
Possible Duplicate: C++: What is the size of an object of an empty class?
Possible Duplicate: Namespace only class visibility in C#/.NET ? What I want is to
Possible Duplicate: c++ publicly inherited class member cannot be used as default argument Nonstatic
Possible Duplicate: Is it possible to print out the size of a C++ class
Possible Duplicate: C++: What is the size of an object of an empty class?
Possible Duplicate: ObjC/Cocoa class for converting size to human-readable string? I'm new in Cocoa.
Possible Duplicate: What data-structure should I use to create my own “BigInteger” class? Out
Possible Duplicate: PHP class instantiation. To use or not to use the parentheses? I
Possible Duplicate: Im not sure how to get the data from my text field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.