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
What is a delegate? Explain.
What is stringbuilder c#?
What is extension method in c sharp?
Is array a list?
What are the types of access modifiers?
Give examples for value types?
Can we instantiate abstract class in c#?
What is sealed class in c#?
Where is c# compiler located?
Explane each and every methods of nterface Queue? Explain About performance issues on retrieving records
Explain the types of errors in c#?
Describe the types of comments in c#?
How Reflection is used and what it's significance ?
What is the difference between an implicit conversion and an explicit conversion?
How to use nullable types in .net?