1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Accessing private member data in C

Discussion in 'C' started by protocoder, May 5, 2007.

  1. protocoder

    protocoder New Member

    Joined:
    May 5, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi

    Is there any way we can access the private member data copiling in only a particular module not visible out side the directory of compilation?

    Thanks
    - AD
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Frankly, I don't understand your question. Could you give a brief example?
     
  3. Zahra

    Zahra New Member

    Joined:
    May 4, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    me 2 , i do not understand your Q . But all what i know that you can not access the private data member . the only way to access them is by using the function member (public) .
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    He is talking about C and not C++ and so he does mean something more than OO or something at least I don't know of. :confused:
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Object oriented design was not invented by software types, regardless of how many buzz words they spout, and how many dictums they hand down to the acolytes. Oog indulged in OOD when he invented the wheel and put an axle in the middle of it, instead of in a tree branch a quarter mile away.

    Mechanical and electronic hardware designers were doing it before it became a buzzword. The butterfly valve of your carburetor is not attached to the hood ornament; the jets are not on the dashboard.

    OOD can be accomplished in assembly language. One can (ostensibly) do better in a high-level language that exposes the concepts more plainly. Nevertheless, when that HLL is translated into machine code, the processor doesn't know the difference. There are no access privileges beyond those imposed in hardware, and those are few and far between.

    I realize that this exposition does not answer the OP's question. It can't, because the OP's question is not lucid or clear.

    One has to think about these things, however, or one is pissing into the wind.
     
  6. protocoder

    protocoder New Member

    Joined:
    May 5, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Sorry C gurus..
    My mistake ... I will explain you..
    This is c project having several 10s of folders. To have abstraction, i manipulated the make in such a way that i can build each module at their respective folders and can build whole project at the root.

    Now .. To ensure that there is no conflict of variables, i have designed such a way that stuctures which need not be used by other modules are built private or built only for the module and make the libraries to link in the root. ..

    Now i have a extention to make where i need to access the structures defined in the some module which is compiled locally, that is those header file structures are not identified out side the module.
    Now i cannot make the header files globally visible for the project which is against our design ...

    So how am i going to tweak it by using c programming logic..

    Example:

    Root ( it has make command for entire project)

    Root
    Dir 1 ( it has make file)
    Dir 2 ( it has make file)
    Dir 3 ( it has make file)
    :
    :
    Dir n ( it has make file)

    Now the make file has public ( seen for global) and Private files ( only for module)

    Now i want to access the structures defined in Dir 3 ( private header files) in Dir 4.

    Solutions rejected:
    One way is to copy the said structure in global declaration to be used. (against design).
    Just build the said header file as public ( Rejected against design having other complications of redefinitions)


    So is there any other way of accessing this structures please...
     
  7. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    So you've made the file inaccessible and now you want it to be accessible. Is that it, in a nutshell?
     
  8. aVague

    aVague New Member

    Joined:
    May 2, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    forex
    if you want to use thing from one modul in another , i think the easiest way is to use adress of that thing, cause adress gives property to read ,what is there
     

Share This Page