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

What is array c#?

524


Why do we need singleton pattern in c#?

485


How do you create user defined data types in c#?

525


Which framework is best for desktop application?

524


Why do we need to override in c#?

526






What is definition in c#?

477


Explain the difference between the system.array.copyto() and system.array.clone()?

496


When should you use generics?

513


What is the difference between and xml documentation tag?

524


What are extender provider components?

475


Why References are stored on heap and variables on stack?

507


if a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?

525


What is the difference between Java and .NET garbage collectors?

509


How do I edit a dll file?

451


What is the meaning of int parse in c#?

504