Question

I'm looking for one special access level like friendship in c# for one member of my class M that I cannot find here : http://msdn.microsoft.com/en-us/library/ba0a1yw2.aspx

Question 1:

Assume I have a secret value like password in my class M, that I don't want any object to have access to it, but for some reasons I want only other instance of class M can read and use this value like: m1.similarity(m2) ==> calculate similarity between m1.password and m2.password

Question 2:

If there is no way to implement the previous example, is it possible to define a friend class like below : anotherclass.similarity(m1,m2)

p.s: This is just an example to make the question clear and I know about possible security impact of method similarity()

Was it helpful?

Solution

Thanks every one, I finally solved the problem with a helper method like this :

int Similiarity (M other)
{
return other.SimiliarityHelper(this.password)
}


int SimiliarityHelper (string otherpass){
return compareString(this.password, otherpass)
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top