Data Hiding In OOP

nidhs

nidhs

@nidhs-EF9dKt Oct 22, 2024
hoe data hiding is possible in object oriented approch?give me an example please..........

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • rahul69

    rahul69

    @rahul69-97fAOs Mar 2, 2013

    nidhs
    hoe data hiding is possible in object oriented approch?give me an example please..........
    For example: private data members of a class are hidden from outside.
  • nidhs

    nidhs

    @nidhs-EF9dKt Mar 2, 2013

    but we can call this data members by their functions.......so how it will be hidden?
  • rahul69

    rahul69

    @rahul69-97fAOs Mar 2, 2013

    nidhs
    but we can call this data members by their functions.......so how it will be hidden?
    Yes we can use functions to access, but then, what is the fun of hiding if u cannot get it when u need it. Think hiding for a simple function(eg add), when a function is called, it's call does not tell actual implementation of that function (ie. how it calculate the value to be returned), similarly when a user clicks add button, he does not know what happens behind scenes. He just know what he needs to know and the rest is hidden.
    Hope it clears it a bit.
  • nidhs

    nidhs

    @nidhs-EF9dKt Mar 2, 2013

    ya...thanks
    but it is also implement in procedural oriented....
    if we create add fun and we also can't see actual implementation.....so what is the different
  • rahul69

    rahul69

    @rahul69-97fAOs Mar 2, 2013

    but it is also implement in procedural oriented....
    Yup u r right, but that was just an analogy to explain the concept, in OOP data is hidden inside private data members so that even objects cannot directly access it,and require function calls for the same.