hi all
i am newbie in c++. can we implement same encapsulation in c?
may be my answer is yes.if we try using static variables it can be possible please somebody help me
hi all
i am newbie in c++. can we implement same encapsulation in c?
may be my answer is yes.if we try using static variables it can be possible please somebody help me
You might wanna try to be a little more elaborate when asking questions - I can barely understand what it is you're asking.
That said, c does not have the same facilities for encapsulation as c++. There is no way of making stuff private/protected, for one.
You can still make a nice design with encapsulation in mind, but the c compiler doesn't really help you very much, as a c++-compiler can.
So I'd say the anser is both yes and no.
Yes there is. It's just not as easy. You can limit to file scope. You can limit to function scope. Both of these can provide a measure of encapsulation. I can write a function which contains all of its own variables that are only used internally. I can then write functions and an interface to use those functions, which are only accessable in a specific way. You will have no access to what is in my first function unless you use the functions I provide to access it.That said, c does not have the same facilities for encapsulation as c++. There is no way of making stuff private/protected, for one.
No, it's not pretty. But it'll work. (Yes, theoreticly you could find away around it, but in C++ you can get past private/protected/constant/etc/etc so the issue is really a nonpoint.)
Quzah.
Hope is the first step on the road to disappointment.