encapsulation in c

This is a discussion on encapsulation in c within the C Programming forums, part of the General Programming Boards category; hi all i am newbie in c++. can we implement same encapsulation in c? may be my answer is yes.if ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    19

    encapsulation in c

    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

  2. #2
    Registered User
    Join Date
    Nov 2004
    Posts
    9
    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.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    That said, c does not have the same facilities for encapsulation as c++. There is no way of making stuff private/protected, for one.
    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.

    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. encapsulation and accessing large maps?
    By dustfinger in forum C++ Programming
    Replies: 7
    Last Post: 09-24-2006, 06:51 PM
  2. Replies: 12
    Last Post: 06-03-2005, 01:13 AM
  3. Replies: 3
    Last Post: 05-25-2005, 01:50 PM
  4. Integration or Encapsulation :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 06-02-2002, 09:14 AM
  5. Encapsulation window creation
    By xds4lx in forum Windows Programming
    Replies: 1
    Last Post: 11-09-2001, 02:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21