Memory allocation for objects, C/C++ Programming

when a class is defined the compiler will not allocate memory.

This is true only for data member not for member function.  As soon as the member function is defined  the required  memory  for that  member  function  is allocated. The  memory  for data member (variable) is allocated only when the object is constructed from the class.

class item

{ int number; float cost; public:

void getdata(int a, float b);

void putdata(void);

};

In the class item the memory is allocated  for getdata and putdata member functions.

Memory is not allocated for number and cost data members.

 

item p;  Now the memory is allocated for data member number and cost. The memory is allocated for each instances of object.

item p,q,r,s;  The memory is allocated for data members of object p,q,r,and s separately for the member function only one memory location which is allocated in the definition.

Posted Date: 9/20/2012 7:55:04 AM | Location : United States







Related Discussions:- Memory allocation for objects, Assignment Help, Ask Question on Memory allocation for objects, Get Answer, Expert's Help, Memory allocation for objects Discussions

Write discussion on Memory allocation for objects
Your posts are moderated
Related Questions
i am using mobile phone if i want to communicate via massage but that should be very secret

Default argument: When the argument is missing then the function will read the default value of the missing argument.  To make use of default argument functionality the argu

c program to implement least cost method

write a program in c language to implement stacks in a single array

Define the Float Data Type of c Language? The float is used to define floating point numbers. The Floating point numbers are stored in 32 bits with 6 digits of precision. Eg


smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

I am doing project on home stay which includes features like add homestay,search,book,delete homestay,

write a function named "fact"that takes one integer arguments,call them "num" and returns as ..............

A r r a y s w i t h i n a c l a s s: I t i s j u s t d ecl a r i n g o r c on s t ru c ti n g a d e r i v e d t