What are the dangers of C’s approach to encapsulation.
Chapter20: Creating A Presentation
Section: Chapter Questions
Problem 5QY
Related questions
Question
What are the dangers of C’s approach to encapsulation.
Expert Solution
Step 1
In C language we achieve encapsulation with the help of data hiding-:
Following are the problems with data hiding-:
- In C we use header files to achieve data hiding , a header file is preprocessed (which is a synonym for copy-pasted) into the implementation file and any file with this header used would be able to access any non static method or public variable defined in the header.
- So with this header file we can access any of the non static method defined in header file using the wrong datatype.
- So protection would only be provided to static variables and all non static variables can be accessed via wrong data type so it is a major problem.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you