Is there any way to access private memebers of an object
from another object?

Answer Posted / rajesh

In C++ we can access private members of one class by the
object of another class,befor that we have to
make "friend"(keyword) the respective member of the first
class to the second class
for ex:
class A
{
private void display();
};

inherits: class B
{
friend void display();
};
Now we can acess the 'display' function using classB
object.We can only make friend to the immediate inherited
class and not to all classes under inheritance.

and in C# we have to create a property as first answer

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are c# strings null terminated?

634


What is desktop example?

586


Give some examples of commonly used i/o classes?

576


What is interface inheritance in c#?

593


What is a static field?

581






What is a generic c#?

573


What is extension method in c# and how to use them?

546


Can you see a loop recorder?

577


What is poco c#?

578


What is Global Assembly Cache (GAC) and what is the purpose of it? (How to make an assembly to public? Steps) How more than one version of an assembly can keep in same place?

667


What is the C# syntax to catch any possible exception?

617


What is the use of console application in c#?

563


Explain briefly the difference between value type and reference type?

645


What is serialization in dot net?

572


Explain anonymous type in c#?

635