Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
What do you mean by hiding? Like in the C++ (object oriented) approach?
Every variable declared in a function is hided to the external world, so to say (if they are declared as static their content will remain between function calls).
You can also declare variables outside to function as being static which means they are visible only inside the file in which you have declared. Thus they are hided from the other files.
Is my answer related to your question? If not please make your question more clear.
In c also using static function u can achieve some extent of data hiding.For details you can search for the static function in c.If any issue let me know.
data hiding in C can be achieved by using two approach as follows:
1. "ordinary" approach. This way, we are not extending the compiler capabilities. This is achieved by using C data structures, pointer to function within that structure and static functions in different modules.
2. "spartan" approach. This way, we are extending the compiler capabilities to support data hiding. An example of this approach is the GTK+ toolkit. In this approach, almost every thing is declared as type void*. The impose on the data type checks is done in a sophisticated way, using macros and lots of "acrobatic" compiler tricks. You can read the Object Oriented C book by Axel-Tobias Schreiner if you are interested in this approach.
You can achieve data hiding in C by doing the following.
1. Create a .h file and tell anyone that includes the file that there exists a struct.
2. Put the struct with all of its datamembers in the .c file.
3. Anyone using the .h file will see that there is a struct available but have to use the access function to use it.
By doing this you have achieved data hiding since no one can directly access your struct or any of their members.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.