This is an example of data hiding:
- struct Data* ptr)
-
-
CreateData(ptr, 5,10, 25.5);
From this you cannot deduce the names of the members of the struct. They are hidden inside CreateData().
Now if the user is given a header file:
- void CreateData(struct Data* arg, int val1, int val2,
-
double vale);
then you still can't know the names of the struct member.
That means I am no free to re-design the struct and since no one knows the member names, then my re-design will not break existing code.
The actual CreateData() function is provided as a shared object (dll) and a header with the function prototype.
You use data hiding to defeat:
- ptr->mema->speed->km = 25.5;
This is called spaghetti code and it means that any change to any of the structs in the string will break this line of code. Code like this effectively freezes the program at the current rev level. Unless you have a computer in the basement and you control all of the terminals.