What are the dangers of C’s approach to encapsulation.

CMPTR
3rd Edition
ISBN:9781337681872
Author:PINARD
Publisher:PINARD
Chapter20: Creating A Presentation
Section: Chapter Questions
Problem 5QY
icon
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

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage