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
Differentiate between dataset and datareader?
What are get and set in c#?
What is the output of TextWriterTraceListener redirected?
What is the signature of a method?
How can I produce an assembly?
Why do we need interfaces in c#?
What is addressof operator?
What is the advantage of constructor?
How to use session under class file of APP_Code folder?
What is callback method in c#?
Define xslt.
What is a value type in c#?
What is the system namespace?
What is the difference between IEnumerator and IEnumerable?
in object oriented programming, how would you describe encapsulation?