answersLogoWhite

0

A class does not consume any memory -- none whatsoever -- it is merely the definition of a type, just as the keyword int is the definition of an integral type. Memory is only consumed when you physically instantiate objects from those types, regardless of whether those types be classes, unions or primitive types.

An object is an actual instance of a class, and its memory footprint is the sum of all its member variables, including any padding required for alignment purposes. the footprint also includes, separately, the memory footprints of each of its base classes. If the class or any of its base classes declare virtual methods, then the memory footprint also includes the virtual table, of which there will be one table per derivative, such that each table has one pair of function pointers per virtual function.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

In object oriented programming when does memory for the class is allocated and why?

While it depends on the specific language, memory for a class is usually allocated when an object of that class is created.


Is there any difference in allocation of the memory of the member of class and object?

A class is the definition of a type -- it consumes no memory in an off itself. An object is an instance of a class, and therefore consumes memory, equal to the total size of all its member variables (attributes), including base class members, plus padding for alignment. If the class declares any virtual methods, a v-table is also created, which consumes additional memory.


What is difference between classes and objects?

Posted by : Govind Singh Lodhithese are the following differences between java class and object.1. Class is a way of bind data member and method in single unit where as a object is a value form of a class or a instance of a class that means allocating sufficient amount of memory space.2. When we define a class ,there is no memory space allocated for data member of a class where as when we create a object of a class memory space is allocated for data members of a class.3.Class will have exist logically where as object will have exist physically.4.One class can have only one name where as corresponding one class we can create multiple object.5.Class load in main memory by using class loader subsystem where as after load class we can create multiple objects of a class.


Define the class object in vb?

A class is a blueprint or a detailed description of a real-world object. An object is an instantiation of a class into memory.


What is an object in Java?

object is an instance of a class. it's used to allocate memory dynamically at run time to access class members.


What difference between package class and object?

A package is a grouping of similar classes. A class is a blue print for making an object. An object is, well, an object.


Is the word classes an object?

Classes is the plural of the word class. A class is not an object in the physical sense, it is an idea, a notion or concept. We typically use a class to define a classification, such as a class of people, a class of study or a class of object. In other words it defines a type.


What are objects in java?

Object is like a variable of the class type which references the memory required by the attributes of the class.


Difference between object declaration and object creation?

Declaration of the object involves only creating the reference variable to the object. Example: class SampleClass{ } Object Declaration: SampleClass obj1; Object Creation: Creating an object involves use of new keyword and actually allocating memory for that object. SampleClass obj2 = new SampleClass ();


How does the memory management is occupied when you are creating an object of a class?

When an object of a class is created, memory management allocates a block of memory to store the object's data members and any associated metadata. This allocation typically occurs on the heap if the object is created dynamically (using new in C++ or similar constructs in other languages), or on the stack if created as a local variable. The memory manager keeps track of the allocated memory, ensuring that it can be accessed and eventually deallocated when the object is no longer needed, preventing memory leaks. Additionally, constructors may be called to initialize the object, further influencing memory usage.


What is difference between struct variable and class object?

structure variable can access the variable but class object can access the function also


What is pointer to an object in c plus plus?

A pointer is simply a variable that stores a memory address. Thus a pointer to an object is simply a variable that stores the memory address of an object. Since pointers are variables, they require memory of their own. Pointers may also be constant, which simply means you cannot change what they point to. Pointers can also be dereferenced to provide indirect access to the memory they point to -- hence they are known as pointers. However, unlike C, pointers are not the same as references. In C++, a reference is simply an alias for a memory address and requires no storage of its own.