Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Accessing private member data in C (http://www.go4expert.com/forums/accessing-private-data-c-t4144/)

protocoder 5May2007 10:10

Accessing private member data in C
 
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

DaWei 5May2007 20:06

Re: Accessing private member data in C
 
Frankly, I don't understand your question. Could you give a brief example?

Zahra 5May2007 20:34

Re: Accessing private member data in C
 
Quote:

Originally Posted by DaWei
Frankly, I don't understand your question. Could you give a brief example?

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) .

shabbir 5May2007 22:10

Re: Accessing private member data in C
 
Quote:

Originally Posted by Zahra
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) .

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:

DaWei 6May2007 06:58

Re: Accessing private member data in C
 
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.

protocoder 6May2007 13:37

Re: Accessing private member data in C
 
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...

DaWei 6May2007 18:27

Re: Accessing private member data in C
 
So you've made the file inaccessible and now you want it to be accessible. Is that it, in a nutshell?

aVague 7May2007 00:47

Re: Accessing private member data in C
 
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


All times are GMT +5.5. The time now is 23:13.