The stupid thing is, why can't you use "public"?

No body is taking a note that i've said i cant change the code in the files ported to me in .obj form.

And u ppl r confused thinking why do i need to access the private member. Think of a scenario that u r to develop an application where u need to just to access the private methods in diff object files by linking them in your application and do some sort of operation which wont reflect on the integrity of any of them. only while linking with ur application u r in need to access the private methods otherwise the private remains private.(mind it i'm defining my behaviour well:))

rest u too know i just cant divulge the details of the project in open communities.

hope u can understand a bit more extent of my proj requirement. I'm not to alter the original object files at any case only i'll be making my application so. rest if they r linked again in some other application the C++ code of conduct is maintained.

this is what reusability is aimed at. i've come up with such a weird requirement that i need to do so. My intentions are never malicious.

No body is taking a note that i've said i cant change the code in the files ported to me in .obj form.

That was the assumption from the beginning, otherwise you would simply change private to public in the code and be done with it.

And u ppl r confused thinking why do i need to access the private member. Think of a scenario that u r to develop an application where u need to just to access the private methods in diff object files by linking them in your application and do some sort of operation which wont reflect on the integrity of any of them. only while linking with ur application u r in need to access the private methods otherwise the private remains private.(mind it i'm defining my behaviour well:))

I can't speak for anyone else, but I understand your need quite well. The problem is that private members are private for a reason. You're not supposed to have access, even if you want it very badly. The correct answer to your question is "tough luck, you can't do it, think of something else".

rest u too know i just cant divulge the details of the project in open communities.

The we have no choice but to assume it's for malicious purposes. Even under a non-disclosure agreement, you can still describe the problem domain that forces you to destroy the reliability of your application for such a little thing as accessing private members.

this is what reusability is aimed at.

Trespassing is far from what reusability is aimed at. What you want to do is trespassing. Doing it is dangerous and completely unnecessary in all possible cases of good software design. Intentionally invoking undefined behaviour should be unthinkable in any professional project. A minor convenience for you now could very well cost your clients a lot of money, a lot of time, and possibly even lives depending on how the application will be used, and you can be held responsible for those things if they're serious enough.

i've come up with such a weird requirement that i need to do so.

Then your design is flawed and needs to be fixed.

No body is taking a note that i've said i cant change the code in the files ported to me in .obj form.

Everyone is taking note of that. Everyone that has answered understands you cannot change the class code.

And u ppl r confused thinking why do i need to access the private member.

No, us ppl r nt cnfsd. We no xctly wut u r sying. (please read this, paragraph 1)

We understand exactly what you want. Four of us have told you exactly what is possible. You refuse to believe us. Everyone has said exactly the same thing to you, and that is "private members cannot be accessed if the class has not given you some way to access it."

We are not confused in the least. The only one that is confused is the one that does not understand my previous post:

OK, here's the synopsis of the problem
1) you have private values in a class and you cannot change the class
2) private values cannot be accessed in a class without the class allowing access
3) if the class does not have methods created that allow access, you cannot access the private values

Final result:
You cannot access private values. They are protected. That's why they are private -- so you can't access them and mess something up.

Please explain what you do not understand about what I just quoted.

And read my point #1 above and explain to me why you say "No body is taking a note that i've said i cant change the code in the files ported to me in .obj form." That is what I don't understand.

yeah you all understood my problem well. But as i've to find a solution(with no malicious intentions, as you all suspect) i'll try to do it on my own. Thanks for the continous help and support. I'll again turn towards you people when I face any other problems. Its a great place to share my problems.

really thanks to all for your support.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.