English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

if an object of derived class is created, then is it creates the instances of all its base classes or not? if so, its the wastage of memory.
When it extends more mutlilevel, it must create all the base class instances. its shows inefficiency in Memory.

What it Happends actually? plz give me explanation about it.

2007-03-10 17:46:42 · 2 answers · asked by sanjeeva 1 in Computers & Internet Programming & Design

2 answers

I derived class is a more specialized version of the base class. It must provide all of the capabilities of the base class. What it does is it creates memory for all of the variables in all of the superclasses, but it does not create new instances of them. When you create an object of a derived class you only get one object, it has the variables from all the base classes, but there is only one object.

2007-03-10 18:14:25 · answer #1 · answered by Math Guy 4 · 2 0

I don't think that there is a memory wastage.
Actually all the methods(except private) of the base class become local to the child class. Its like macros in C i.e. entire code is repeated.
So only 1 object but all methods.

2007-03-10 19:22:07 · answer #2 · answered by borngenious 2 · 0 0

fedest.com, questions and answers