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
How does bitwise xor work?
Why do we use lambda expression in c#?
What are the uses of namespaces?
How many bytes is an int?
Which is faster dictionary or list?
Can you specify an access modifier for an enumeration?
What do you mean by the delegate in c#?
Explain About Web.config
What is difference between destructor and finalize?
Is there a way of specifying which block or loop to break out of when working with nested loops?
How can we set the class to be inherited, but prevent the method from being over-ridden?
Why do we use static class in c#?
What is hash c#?
What are Types of assemblies that can be created in dotnet
Who introduced c#?