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

Friday 19 June 2020

Type Checking In C++ Pointer | Type Checking In C++ Pointer Types| Type Checking In C++ Pointer Example| Type Checking In C++ Pointer In Hindi

Type Checking In C++ Pointer


In c++ different type of pointer and some are already like pointer they show there behavior according to datatype.

If want to check type checking then we have to use 2 types pointer.

1.Void

2.Null

1.Void

A void pointer is a general-purpose pointer that can hold the address of any data type, but it is not associated with any data type. we cannot assign the address of a variable to the variable of a different data type.

image of void pointer in type checking

Fig: Void Pointer


Example:

void *p;

Program:

#inlcude<iostream.h>

#include<conio.h>

void main()

{

int a;

void *p;

int b;

cout<<”example of void datatype/n”;

p=&a;

cout<<*(int *)a;

p=&b;

cout<<*(int *)b;

getch();

}


Output:

Example of void datatype

0767


2.Null

Just like normal variables, pointers are not initialized when they are instantiated. Unless a value is assigned, a pointer will point to some garbage address by default.

Besides memory addresses, there is one additional value that a pointer can hold: a null value. A null value is a special value that means the pointer is not pointing at anything. A pointer holding a null value is called a null pointer.

image of null pointer in type checking

Fig: NULL Pointer

Example:

int *p=null;


Program:

#inlcude<iostream.h>

#include<conio.h>

void main()

{

int a;

int *p=null;

cout<<”input one number”;

cin>>a;

p=&a;

cout<<*p;

getch();

}


Output:

Input one no 23

23

 


No comments:

Post a Comment