Advance Java coaching, angular JS, Basic computer course, C programming language, c++ language, Education, Engineering Courses, Java, Java Course In Satellite - Bopal Ahmedabad, online computer coaching, PHP coaching, programming language, Python, TCCI computer coaching

Why-does-inheritance-increase-class-size-in-C? tccicomputercoaching.com

Inheritance reuses code. So the overall effect is to reduce the compiled code size less than 2x for a base class and an inherited class. Only what is new in the inherited class adds code to the compiled binary, only data members added to the inherited class increase the instance data size.

inheri-class-inC_simpleAn inherited class “contains” all the necessary code and data of the base class, plus whatever is unique to the inherited class. But “contains” is not copies, it is referenced with a few bytes and function dispatch table entries.

This is the advantage of inheriting code over rewriting the same code for an only slightly different class, destined to be used primarily for the same purpose and in the same manner as the base class.

But in the modern age size of class recipe in the compiled code is not really a concern usually.

But as stated elsewhere, very little extra storage is needed if there is not significantly more data members in the inherited class.

To learn more about Inheritance at TCCI.

Call us @ 98256 18292.

Visit us @ http://tccicomputercoaching.com/

 

Leave a comment