new problem C# friend?

guest31ro

Member
Joined
May 17, 2003
Messages
21
class B;
class A
{
int Func1( B& b ) ;
int Func2( B& b ) ;
};

class B
{
private:
int _b;
friend int A::Func1( B& ); // Grant friend access to one
// function in class B.
};
int A::Func1( B& b ) { return b._b; } // OK: this is a friend.
int A::Func2( B& b ) { return b._b; } // Error: _b is a private member.

I want to declare in C# a function as friend, like up there ....
It is posible, and how?
 
Originally posted by guest31ro
I want to acces a function or variable from a class without creating an object of that class.

It sounds to me like you are looking for the static modifier.
Snippet from MSDN

Members of a class are either static members or instance members. Generally speaking, it is useful to think of static members as belonging to classes and instance members as belonging to objects (instances of classes)...
 
[mshelp]ms-help://MS.VSCC/MS.MSDNVS/csref/html/vclrfstaticpg.htm[/mshelp]

Try that link and the example code in MSDN
 
Back
Top