TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Saturday 20 June 2020

Initialization Allocating Memory In C++| Initialization Allocating Memory In C++ Program|Initialization Allocating Memory In C++ In Hindi

Initialization Allocating Memory In C++


Whenever we want a variable to dynamic memory allocated so we have to use new keyword for that time or if we want to new keyword through  allocated memory to destroy so we have to use delete keyword. Like that we can do memory initialization or deletion.

image of Initialization Allocating Memory In C++
Fig: Initialization Allocating Memory In C++

Syntax:

data type *variable name=NULL;

variable name=new data type;

*variable name=value;


Example:

int *a=NULL;

a=new int;

*a=20;


Program:

#include<iostream.h>

#include<conio.h>

void main()

{

int *a=NULL;

a=new int;

*a=20;

cout<<”example of initialization allocated memory”;

cout<<a;

delete a;

getch();

}


Output:

Example of initialization allocated memory 0x8f910dc6


No comments:

Post a Comment