{"id":25553487,"date":"2023-02-12T20:00:16","date_gmt":"2023-02-12T14:30:16","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25553487"},"modified":"2023-05-11T11:33:46","modified_gmt":"2023-05-11T06:03:46","slug":"data-hiding-in-cpp","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/","title":{"rendered":"Data Hiding in C++ &#8211; Introduction, Example"},"content":{"rendered":"<p><a href=\"https:\/\/entri.app\/blog\/difference-between-data-hiding-and-abstraction\/\" target=\"_blank\" rel=\"noopener\">Data hiding<\/a> is a method for concealing data members, which are internal features of an object. It is an approach to object-oriented programming. Data concealing assures, or maybe we should say guarantees, that only members of the class have access to the data. It preserves the data&#8217;s integrity. To restrict direct access from outside the class, data hiding refers to concealing internal data within the class. By reducing the interdependencies between software components, data hiding also contributes to a reduction in system complexity and an improvement in resilience. By employing the private access specifier, data may be hidden. Data hiding, or simply concealing data members, is a programming method used in object-oriented environments. Data hiding maintains object integrity and ensures that class members have limited access to data.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/entri.app\/course\/data-science-and-machine-learning-course\/\" target=\"_blank\" rel=\"noopener\">Learn Full Stack Development with experts! Explore Here!<\/a><\/p>\n<p>A class&#8217;s members are better protected when data is hidden. There are access modifiers like public, private, and protected in programming languages like Java. Other classes&#8217; objects have access to public data members and methods. However, objects belonging to the same class and its subclasses can access protected members. Additionally, only members of the class have access to private members. As a result, these access modifiers aid in keeping the members safe. The private access modifier can be used by a programmer to prevent objects of other classes from accessing a class&#8217;s members when it is essential. Then, only members of the class may access the data. Additionally, it is possible to make the data members public while keeping them private (getters and setters).<\/p>\n<p><strong><div class=\"lead-gen-block\"><a href=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/05\/1_merged-3_compressed.pdf\" data-url=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/05\/1_merged-3_compressed.pdf\" class=\"lead-pdf-download\" data-id=\"25556853\"><\/strong><\/p>\n<p style=\"text-align: center;\"><button class=\"btn btn-default\">Free SQL Tutorial for Beginners &#8211; Download PDF<\/button><\/p>\n<p><strong><\/a><\/div><\/strong><\/p>\n<h2>Introduction to Data Hiding in C++<\/h2>\n<p>Since data is the most delicate and unstable part of a program, tampering with it can lead to erroneous results and jeopardize data integrity. Data hiding is useful in this situation. Data concealing aims to shield information inside a class from unauthorized access and prevents unnecessary intrusion from outside the class. In C++, data hiding ensures restricted data access, protects the integrity of the object, and hinders accidental or deliberate modifications to the program. In C++, the technique of concealing computer code from object members is known as data hiding. If an object member tries to access hidden data, the program will produce an error. The programmer cannot connect to data that has been buried since it is inaccurate due to this safety feature. Internal parts that aren&#8217;t expected to be used by users are usually hidden. In C++, abstraction and encapsulation are two more OOP characteristics that go hand in hand with data hiding.<\/p>\n<h3>Example of Data Hiding in C++<\/h3>\n<p>To conceal internal object information, object-oriented programming (OOP) uses the software development method known as data hiding (data members). Data hiding guarantees that class members have exclusive access to data and safeguards object integrity by avoiding accidental or deliberate alterations. Let us look at an example of data hiding in C++ by finding out the area of a rectangle:<\/p>\n<p>#include&lt;iostream&gt;<\/p>\n<p>using namespace std;<\/p>\n<p>class Rectangle<\/p>\n<p>{<\/p>\n<p>public :<\/p>\n<p>int length;<\/p>\n<p>int breadth;<\/p>\n<p>int area()<\/p>\n<p>{<\/p>\n<p>return length*breadth;<\/p>\n<p>}<\/p>\n<p>int perimeter()<\/p>\n<p>{<\/p>\n<p>return 2*(length+breadth);<\/p>\n<p>}<\/p>\n<p>};<\/p>\n<p>int main()<\/p>\n<p>{<\/p>\n<p>Rectangle r,*p;\/\/Using Stack<\/p>\n<p>p=&amp;r;<\/p>\n<p>p-&gt;length=5;<\/p>\n<p>p-&gt;breadth=10;<\/p>\n<p>cout&lt;&lt;&#8220;Stack Area : &#8220;&lt;&lt;p-&gt;area()&lt;&lt;endl;<\/p>\n<p>&nbsp;<\/p>\n<p>Rectangle *h=new Rectangle(); \/\/Using Heap<\/p>\n<p>h-&gt;length=10;<\/p>\n<p>h-&gt;breadth=10;<\/p>\n<p>cout&lt;&lt;&#8220;Heap Area : &#8220;&lt;&lt;h-&gt;area();<\/p>\n<p>return 0;<\/p>\n<p>}<\/p>\n<p>Output: Stack Area: 50<\/p>\n<p>Heap Area: 100<\/p>\n<h4>Data Abstraction<\/h4>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Abstraction_(computer_science)\" target=\"_blank\" rel=\"noopener\">Data abstraction<\/a> is a method for simply displaying to the user the essential program interface and concealing the more intricate implementation details. Let&#8217;s examine a real-world case to have a better understanding. Check out what&#8217;s on your television. The television can be turned on and off, the channel can be changed, the volume can be changed, and speakers and external devices like VCRs and DVD players can be connected. You aren&#8217;t aware of the television&#8217;s interior workings, though. Data abstraction shields class implementation from unexpected mistakes and enables it to adapt to evolving needs or problem reports without needing user involvement.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/entri.app\/course\/data-science-and-machine-learning-course\/\" target=\"_blank\" rel=\"noopener\">Elevate your career with Entri Elevate! Explore Here!<\/a><\/p>\n<p>Data abstraction is a typical technique used by modern <a href=\"https:\/\/entri.app\/blog\/8-best-front-end-programming-languages\/\" target=\"_blank\" rel=\"noopener\">programming languages<\/a> that employ OOP approaches to hide the low-level details of the programming constructs that define the underlying logic, which in turn simplifies and speeds up the development process. Instead of focusing on functions or logic, object-oriented programming centers software architecture on data objects. A crucial aspect of OOP is data abstraction, which is carried out through classes and objects. The definition of a class is a template that groups associated properties and methods into a named package. It is a unique kind of thing that acts as a design template for making additional objects. A class can also have subclasses, which can inherit all or some of the class&#8217;s characteristics and functions, creating a kind of class hierarchy. Subclasses are also allowed to create their properties and functions.<\/p>\n<h4>Data Encapsulation<\/h4>\n<p>The act of combining data with related functions into a single entity known as a class is known as data encapsulation. Simply said, if you have a property that is invisible from the outside of an object and bundles it with methods that provide read or write access to it, you may hide sensitive information and restrict access to the internal state of a thing. As a consequence, depending on the techniques you select, it&#8217;s up to you to decide whether an attribute may be read and modified, read-only, or not visible at all. Data abstraction is a method of exposing only the interfaces and shielding the user from the implementation details. Data encapsulation is a method of combining the data and the functions that utilize it.<\/p>\n<h4>Difference Between Data Hiding and Data Encapsulation<\/h4>\n<p>Encapsulation and Data Hiding are two OOP concepts. Data hiding is the process of preventing unauthorized access to the class&#8217;s members. The act of encapsulating data elements and method calls into a single entity is called encapsulation. That is the distinction between data encapsulation and data concealing. A method of achieving data concealing is encapsulation.<\/p>\n<ul>\n<li>By limiting unintentional or intentional modifications, data hiding assures exclusive data access to class members and maintains object integrity. A technique used in OOP called encapsulation groups together the data and the methods that work with it.<\/li>\n<li>The goal of data concealing is to protect the data while obscuring its complexity. The goal of encapsulation is to mask the system&#8217;s complexity.<\/li>\n<li>Data protection is achieved by data concealing. A technique for accomplishing data concealing is encapsulation.<\/li>\n<li>Using the private access modifier, data is hidden. Private, protected, and public access modifiers are used in encapsulation.<\/li>\n<\/ul>\n<h4>Access Specifiers<\/h4>\n<p>By allowing the construction of user-defined types, or classes, C++ provides data hiding and, by extension, data abstraction and data encapsulation. Access specifiers are a class of keywords that specify the range of this newly generated class&#8217;s members. Private, protected, and public access specifiers are the three main forms of protection or access specifiers that are typically accessible inside a category and are used to develop a class&#8217;s encapsulation capabilities. Variables and functions of a type can be accessed in different ways depending on the access specifiers that are used. In most cases, a class&#8217;s actions are public while its data is private to prevent instances of unintentional tampering. However, there are no limitations on accessibility within a rank.<\/p>\n<h4>Application of Data Hiding<\/h4>\n<ol>\n<li>Data that is erratic and sensitive are frequently subject to data concealment. The efficient and speedy operation of software depends on this kind of data. Due to unauthorized access, the ensuing data changes are irreversible and necessitate a complete rewrite on the part of the programmer before future usage.<\/li>\n<li>Data concealment shields students against unintended oversights. Typically, a class consists of several linked fields that must all be in a trustworthy condition. Let&#8217;s say a programmer is given direct access to any of these fields. In such circumstances, there&#8217;s a chance that you may make changes to one area without making changes to crucial linked areas, which would put your class in a conflicting situation.<\/li>\n<\/ol>\n<h4>Wrapping Up<\/h4>\n<p>The advantages of data hiding in C++ are numerous. It helps reduce the complexity and unpredictable nature of data. It makes the software more reusable. Decreasing interdependencies between software components also contribute to a reduction in system complexity and an improvement in resilience.<\/p>\n<h5>Data Hiding in C++ &#8211; Introduction, Example: FAQs<\/h5>\n<ul>\n<li>What does object-oriented programming&#8217;s term &#8220;encapsulation&#8221; mean?<\/li>\n<\/ul>\n<p>Data and the programming that manipulates it can be connected through encapsulation. It is a method for making the data abstraction visible to the outside world while concealing the data implementation specifics.<\/p>\n<ul>\n<li>What does object-oriented programming&#8217;s abstraction mean?<\/li>\n<\/ul>\n<p>In object-oriented programming, abstraction is a method for separating class interfaces from the implementation specifics of each particular object.<\/p>\n<ul>\n<li>How do classes and objects in object-oriented programming interact with one another?<\/li>\n<\/ul>\n<p>The cornerstones of object-oriented (OO) programming are classes and objects. A programming paradigm known as object-oriented programming employs objects and classes to simulate the actual world.<\/p>\n<h4><strong>Related Articles<\/strong><\/h4>\n<div class=\"table-responsive wprt_style_display\">\n<div class=\"table-responsive wprt_style_display\">\n<table class=\"table\" dir=\"ltr\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col width=\"329\" \/>\n<col width=\"309\" \/><\/colgroup>\n<tbody>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Syllabus&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-village-field-assistant-vfa-syllabus-exam-pattern\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/data-science-jobs-in-kerala\/\" target=\"_blank\" rel=\"noopener\">Data Science Jobs in Kerala<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Mock Test&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-free-mock-test\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/importance-of-data-preprocessing-in-machine-learning\/\" target=\"_blank\" rel=\"noopener\">Importance of Data Preprocessing in Machine Learning<\/a><\/strong><\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Exam Date&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-exam-date\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/what-is-a-data-science-pipeline-ultimate-guide\/\" target=\"_blank\" rel=\"noopener\">What is a Data Science Pipeline?<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Video Course&quot;}\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/top-data-types-of-python-python-data-types\/\" target=\"_blank\" rel=\"noopener\">Top Data Types of Python<\/a><\/strong><\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Application Form&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-apply-online\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/what-is-data-interpretation-methods-and-benefits\/\" target=\"_blank\" rel=\"noopener\">What is Data Interpretation? Methods and Benefits<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Study Materials&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-study-material\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/data-analysis-process-methods-types\/\" target=\"_blank\" rel=\"noopener\">Data Analysis \u2013 Process, Methods, Types<\/a><\/strong><\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Vacancy&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-vacancy\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/data-science-life-cycle\/\" target=\"_blank\" rel=\"noopener\">What is Data Science Life Cycle?<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Interview Questions&quot;}\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/best-full-stack-developer-course-with-placement\/\" target=\"_blank\" rel=\"noopener\">Best Full Stack Developer Course with Placement<\/a><\/strong><\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Admit Card&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-admit-card\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/future-of-python-developers-in-2022\/\" target=\"_blank\" rel=\"noopener\">Future of Python Developers<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Job Profile&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-job-profile\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/use-of-data-science-in-banking-fraud-detection\/\" target=\"_blank\" rel=\"noopener\">Use of Data Science in Banking for Fraud Detection<\/a><\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"modal\" id=\"modal25556853\"><div class=\"modal-content\"><span class=\"close-button\">&times;<\/span>\n\n<div class=\"wpcf7 no-js\" id=\"wpcf7-f25556853-o1\" lang=\"en-US\" dir=\"ltr\" data-wpcf7-id=\"25556853\">\n<div class=\"screen-reader-response\"><p role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"><\/p> <ul><\/ul><\/div>\n<form action=\"\/blog\/wp-json\/wp\/v2\/posts\/25553487#wpcf7-f25556853-o1\" method=\"post\" class=\"wpcf7-form init\" aria-label=\"Contact form\" novalidate=\"novalidate\" data-status=\"init\">\n<fieldset class=\"hidden-fields-container\"><input type=\"hidden\" name=\"_wpcf7\" value=\"25556853\" \/><input type=\"hidden\" name=\"_wpcf7_version\" value=\"6.1.4\" \/><input type=\"hidden\" name=\"_wpcf7_locale\" value=\"en_US\" \/><input type=\"hidden\" name=\"_wpcf7_unit_tag\" value=\"wpcf7-f25556853-o1\" \/><input type=\"hidden\" name=\"_wpcf7_container_post\" value=\"0\" \/><input type=\"hidden\" name=\"_wpcf7_posted_data_hash\" value=\"\" \/><input type=\"hidden\" name=\"_wpcf7cf_hidden_group_fields\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_hidden_groups\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_visible_groups\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_repeaters\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_steps\" value=\"{}\" \/><input type=\"hidden\" name=\"_wpcf7cf_options\" value=\"{&quot;form_id&quot;:25556853,&quot;conditions&quot;:[],&quot;settings&quot;:{&quot;animation&quot;:&quot;yes&quot;,&quot;animation_intime&quot;:200,&quot;animation_outtime&quot;:200,&quot;conditions_ui&quot;:&quot;normal&quot;,&quot;notice_dismissed&quot;:false,&quot;notice_dismissed_update-cf7-5.9.8&quot;:true,&quot;notice_dismissed_update-cf7-6.1.1&quot;:true}}\" \/>\n<\/fieldset>\n<p><span class=\"wpcf7-form-control-wrap\" data-name=\"full_name\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-text wpcf7-validates-as-required\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Name\" value=\"\" type=\"text\" name=\"full_name\" \/><\/span><br \/>\n<span class=\"wpcf7-form-control-wrap\" data-name=\"phone\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-tel wpcf7-validates-as-required wpcf7-text wpcf7-validates-as-tel\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Phone\" value=\"\" type=\"tel\" name=\"phone\" \/><\/span><br \/>\n<span class=\"wpcf7-form-control-wrap\" data-name=\"email_id\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-email wpcf7-text wpcf7-validates-as-email\" aria-invalid=\"false\" placeholder=\"Email\" value=\"\" type=\"email\" name=\"email_id\" \/><\/span><br \/>\n<span class=\"wpcf7-form-control-wrap\" data-name=\"language\"><select class=\"wpcf7-form-control wpcf7-select wpcf7-validates-as-required\" aria-required=\"true\" aria-invalid=\"false\" name=\"language\"><option value=\"\">Language<\/option><option value=\"Malayalam\">Malayalam<\/option><option value=\"Tamil\">Tamil<\/option><option value=\"Telugu\">Telugu<\/option><option value=\"Kannada\">Kannada<\/option><option value=\"Hindi\">Hindi<\/option><\/select><\/span><br \/>\n<span class=\"wpcf7-form-control-wrap\" data-name=\"course\"><select class=\"wpcf7-form-control wpcf7-select wpcf7-validates-as-required course-field-select\" aria-required=\"true\" aria-invalid=\"false\" name=\"course\"><option value=\"\">Upskill in<\/option><option value=\"Commerce\">Commerce<\/option><option value=\"Coding\">Coding<\/option><option value=\"Robotics &amp; AI Course\">Robotics &amp; AI Course<\/option><option value=\"Stock Market Course\">Stock Market Course<\/option><option value=\"Spoken English\">Spoken English<\/option><option value=\"German Language\">German Language<\/option><option value=\"Montessori Teacher Training\">Montessori Teacher Training<\/option><option value=\"IELTS\">IELTS<\/option><option value=\"OET\">OET<\/option><option value=\"MEP\">MEP<\/option><option value=\"Embedded System Software Engineering\">Embedded System Software Engineering<\/option><option value=\"Quantity Surveying\">Quantity Surveying<\/option><option value=\"Hospital and Healthcare Administration\">Hospital and Healthcare Administration<\/option><option value=\"Yoga TTC\">Yoga TTC<\/option><option value=\"Digital Marketing\">Digital Marketing<\/option><option value=\"AI for Teachers\">AI for Teachers<\/option><option value=\"Arabic\">Arabic<\/option><\/select><\/span>\n<\/p>\n<div data-id=\"group-coding\" data-orig_data_id=\"group-coding\" data-clear_on_hide class=\"\" data-class=\"wpcf7cf_group\">\n\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"course_name\"><select class=\"wpcf7-form-control wpcf7-select wpcf7-validates-as-required course-name-select\" aria-required=\"true\" aria-invalid=\"false\" name=\"course_name\"><option value=\"\">Select Course<\/option><option value=\"Full Stack Development\">Full Stack Development<\/option><option value=\"Data Science and ML\">Data Science and ML<\/option><option value=\"Software Testing\">Software Testing<\/option><option value=\"Python Programming\">Python Programming<\/option><option value=\"AWS Training\">AWS Training<\/option><\/select><\/span>\n\t<\/p>\n<\/div>\n<div data-id=\"group-accounting\" data-orig_data_id=\"group-accounting\" data-clear_on_hide class=\"\" data-class=\"wpcf7cf_group\">\n\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"course_name\"><select class=\"wpcf7-form-control wpcf7-select wpcf7-validates-as-required course-name-select\" aria-required=\"true\" aria-invalid=\"false\" name=\"course_name\"><option value=\"\">Select Course<\/option><option value=\"Business Accounting\">Business Accounting<\/option><option value=\"CMA USA\">CMA USA<\/option><option value=\"Enrolled Agent\">Enrolled Agent<\/option><option value=\"SAP FICO\">SAP FICO<\/option><option value=\"SAP MM\">SAP MM<\/option><option value=\"SAP SD\">SAP SD<\/option><option value=\"ACCA\">ACCA<\/option><option value=\"Tally\">Tally<\/option><option value=\"UAE Accounting\">UAE Accounting<\/option><option value=\"GST\">GST<\/option><\/select><\/span>\n\t<\/p>\n<\/div>\n<p><span class=\"wpcf7-form-control-wrap\" data-name=\"education\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-text wpcf7-validates-as-required\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Educational qualification\" value=\"\" type=\"text\" name=\"education\" \/><\/span>\n<\/p>\n<div style=\"display:none\">\n<input class=\"wpcf7-form-control wpcf7-hidden course-name-input\" value=\"\" type=\"hidden\" name=\"course_name\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-source\" value=\"\" type=\"hidden\" name=\"utm_source\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-medium\" value=\"\" type=\"hidden\" name=\"utm_medium\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-campaign\" value=\"\" type=\"hidden\" name=\"utm_campaign\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-content\" value=\"\" type=\"hidden\" name=\"utm_content\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-term\" value=\"\" type=\"hidden\" name=\"utm_term\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden blog-url\" value=\"\" type=\"hidden\" name=\"blog_url\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden post-category-name\" value=\"\" type=\"hidden\" name=\"post_category_name\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden post-author-name\" value=\"\" type=\"hidden\" name=\"post_author_name\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden file-url\" value=\"\" type=\"hidden\" name=\"file_url\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden video-url\" value=\"\" type=\"hidden\" name=\"video_url\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden courseid\" value=\"\" type=\"hidden\" name=\"course_id\" \/>\n<\/div>\n<div class=\"cf7-cf-turnstile\" style=\"margin-top: 0px; margin-bottom: -15px;\"> <div id=\"cf-turnstile-cf7-249423216\" class=\"cf-turnstile\" data-sitekey=\"0x4AAAAAABVigxtkiZeGTu5L\" data-theme=\"light\" data-language=\"auto\" data-size=\"normal\" data-retry=\"auto\" data-retry-interval=\"1000\" data-action=\"contact-form-7\" data-appearance=\"always\"><\/div> <script>document.addEventListener(\"DOMContentLoaded\", function() { setTimeout(function(){ var e=document.getElementById(\"cf-turnstile-cf7-249423216\"); e&&!e.innerHTML.trim()&&(turnstile.remove(\"#cf-turnstile-cf7-249423216\"), turnstile.render(\"#cf-turnstile-cf7-249423216\", {sitekey:\"0x4AAAAAABVigxtkiZeGTu5L\"})); }, 0); });<\/script> <br class=\"cf-turnstile-br cf-turnstile-br-cf7-249423216\"> <style>#cf-turnstile-cf7-249423216 { margin-left: -15px; }<\/style> <script>document.addEventListener(\"DOMContentLoaded\",function(){document.querySelectorAll('.wpcf7-form').forEach(function(e){e.addEventListener('submit',function(){if(document.getElementById('cf-turnstile-cf7-249423216')){setTimeout(function(){turnstile.reset('#cf-turnstile-cf7-249423216');},1000)}})})});<\/script> <\/div><br\/><input class=\"wpcf7-form-control wpcf7-submit has-spinner\" type=\"submit\" value=\"Submit\" \/>\n<\/p><div class=\"wpcf7-response-output\" aria-hidden=\"true\"><\/div>\n<\/form>\n<\/div>\n\n<\/div><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Data hiding is a method for concealing data members, which are internal features of an object. It is an approach to object-oriented programming. Data concealing assures, or maybe we should say guarantees, that only members of the class have access to the data. It preserves the data&#8217;s integrity. To restrict direct access from outside the [&hellip;]<\/p>\n","protected":false},"author":91,"featured_media":25553488,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1864,1904,1841],"tags":[],"class_list":["post-25553487","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-data-science-ml","category-entri-elevate","category-entri-skilling"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Data Hiding in C++ - Entri Blog<\/title>\n<meta name=\"description\" content=\"Explained Data Hiding. Explained Data Abstraction and Data Encapsulation. Listed the difference between Data Hiding and Data Encapsulation\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Data Hiding in C++ - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"Explained Data Hiding. Explained Data Abstraction and Data Encapsulation. Listed the difference between Data Hiding and Data Encapsulation\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-12T14:30:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-11T06:03:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Kiranlal VT\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kiranlal VT\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/\"},\"author\":{\"name\":\"Kiranlal VT\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/5c2c274e024447e3b9e8b4ee88389e4f\"},\"headline\":\"Data Hiding in C++ &#8211; Introduction, Example\",\"datePublished\":\"2023-02-12T14:30:16+00:00\",\"dateModified\":\"2023-05-11T06:03:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/\"},\"wordCount\":1619,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png\",\"articleSection\":[\"Articles\",\"Data Science and Machine Learning\",\"Entri Elevate\",\"Entri Skilling\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/\",\"url\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/\",\"name\":\"What is Data Hiding in C++ - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png\",\"datePublished\":\"2023-02-12T14:30:16+00:00\",\"dateModified\":\"2023-05-11T06:03:46+00:00\",\"description\":\"Explained Data Hiding. Explained Data Abstraction and Data Encapsulation. Listed the difference between Data Hiding and Data Encapsulation\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png\",\"width\":820,\"height\":615,\"caption\":\"Data Hiding in C++ - Introduction, Example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Data Science and Machine Learning\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/data-science-ml\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Data Hiding in C++ &#8211; Introduction, Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/5c2c274e024447e3b9e8b4ee88389e4f\",\"name\":\"Kiranlal VT\",\"url\":\"https:\/\/entri.app\/blog\/author\/kiranlal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Data Hiding in C++ - Entri Blog","description":"Explained Data Hiding. Explained Data Abstraction and Data Encapsulation. Listed the difference between Data Hiding and Data Encapsulation","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/","og_locale":"en_US","og_type":"article","og_title":"What is Data Hiding in C++ - Entri Blog","og_description":"Explained Data Hiding. Explained Data Abstraction and Data Encapsulation. Listed the difference between Data Hiding and Data Encapsulation","og_url":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2023-02-12T14:30:16+00:00","article_modified_time":"2023-05-11T06:03:46+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png","type":"image\/png"}],"author":"Kiranlal VT","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Kiranlal VT","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/"},"author":{"name":"Kiranlal VT","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/5c2c274e024447e3b9e8b4ee88389e4f"},"headline":"Data Hiding in C++ &#8211; Introduction, Example","datePublished":"2023-02-12T14:30:16+00:00","dateModified":"2023-05-11T06:03:46+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/"},"wordCount":1619,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png","articleSection":["Articles","Data Science and Machine Learning","Entri Elevate","Entri Skilling"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/","url":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/","name":"What is Data Hiding in C++ - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png","datePublished":"2023-02-12T14:30:16+00:00","dateModified":"2023-05-11T06:03:46+00:00","description":"Explained Data Hiding. Explained Data Abstraction and Data Encapsulation. Listed the difference between Data Hiding and Data Encapsulation","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/data-hiding-in-cpp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/02\/Untitled2351.png","width":820,"height":615,"caption":"Data Hiding in C++ - Introduction, Example"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/data-hiding-in-cpp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Data Science and Machine Learning","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/data-science-ml\/"},{"@type":"ListItem","position":4,"name":"Data Hiding in C++ &#8211; Introduction, Example"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/5c2c274e024447e3b9e8b4ee88389e4f","name":"Kiranlal VT","url":"https:\/\/entri.app\/blog\/author\/kiranlal\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25553487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/91"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25553487"}],"version-history":[{"count":5,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25553487\/revisions"}],"predecessor-version":[{"id":25559949,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25553487\/revisions\/25559949"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25553488"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25553487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25553487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25553487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}