C++ Abstraction in Hindi – OOP’s In Hindi

C++
Loading...

C++ Abstraction in Hindi – Abstraction Ye Object-Oriented Programming Ka Bahut Hi Accha Feature Hai And CPP Abstraction Se Aap Data Hide Kar Sakte Hai |

While Loops And Do-While Loops

C++ Abstraction in Hindi

Data Abstraction Ka Istemal Data Ko Hide Karne Ke Liye Istemal Kiya Jata Hai, Iska Matlab Ye Hai, Data Hide Hone Ke Sath Sath Data Abstraction Aapna Kam Kar Deta Hai |

Data Abstraction can be achieved in two ways:

  • Abstraction using classes
  • Abstraction in header files.
Data Abstraction in C++

Abstraction using access specifiers

Data Abstraction Me Ham Keval Two Access Specifiers Ka Istemal Kar Sakte Hai – public and private |

  • public – public access specifier ka Istemal Ham Class Ke Bagar Or Ander Kar Sakte Hai |
  • private – private access specifier ka Istemal Ham class Ke Ander Hi kar Sakte Hai |

Example 1:

#include <iostream> 
using namespace std; 

class implementAbstraction 
{ 
	private: 
		int a, b; 

	public: 
	
		// method to set values of 
		// private members 
		void set(int x, int y) 
		{ 
			a = x; 
			b = y; 
		} 
		
		void display() 
		{ 
			cout<<"a = " <<a << endl; 
			cout<<"b = " << b << endl; 
		} 
}; 

int main() 
{ 
	implementAbstraction obj; 
	obj.set(10, 20); 
	obj.display(); 
	return 0; 
} 

Output:

a = 10
b = 20

Yadi Aapne  HTML Full Course  And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

Leave a Reply

Your email address will not be published.