Memory allocation for objects, C/C++ Programming

Assignment Help:

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.


Related Discussions:- Memory allocation for objects

Big-m method, big-m method operation reseach in progrmme c++..

big-m method operation reseach in progrmme c++..

Programming, Write a program that writes your name on the monitor ten times...

Write a program that writes your name on the monitor ten times. Write this program three times, once with each looping method.

Minimum shelf, At a shop of marbles, packs of marbles are prepared. Packets...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

C program for count sorted characters, # include stdio.h> # include coni...

# include stdio.h> # include conio.h> # include string.h> void main()   {           int i=0,j=0;           char a[100],temp;           clrscr();

Cipher: Decrypt and Encrypt, You must write a program that can both decrypt...

You must write a program that can both decrypt and encrypt a single word that is entered by the user. The initial choice of encryption and decryption is left up to the user. Addi

Change to palindrome, A palindrome is a string that reads the same from bot...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Explain about evaluation of expression in c language, Explain about Evaluat...

Explain about Evaluation of Expression in c language? An Expressions are evaluated using an assignment statement of the form: variable = expression; The Variable is any v

Example of switch case statement, #include #include #include void* m...

#include #include #include void* memorycopy (void *des, const void *src, size_t count) {   size_t n = (count + 7) / 8;   char* destination = (char *) des;   char* source =

Develop an auto-click bot, What I need is an auto-click bot. The auto-click...

What I need is an auto-click bot. The auto-click bot would ask me for a url(or it would be pre-defined too) so that it loads that specific url and click an ad automatically. This w

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd