guest31ro Posted May 24, 2003 Posted May 24, 2003 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? Quote
guest31ro Posted May 24, 2003 Author Posted May 24, 2003 I want to acces a function or variable from a class without creating an object of that class. Quote
Leaders John Posted May 24, 2003 Leaders Posted May 24, 2003 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)... Quote "These Patriot playoff wins are like Ray Charles songs, Nantucket sunsets, and hot fudge sundaes. Each one is better than the last." - Dan Shaughnessy
guest31ro Posted May 25, 2003 Author Posted May 25, 2003 If I declare in Class A a static variable how do I change it's value in Class B? Quote
Leaders John Posted May 25, 2003 Leaders Posted May 25, 2003 [mshelp]ms-help://MS.VSCC/MS.MSDNVS/csref/html/vclrfstaticpg.htm[/mshelp] Try that link and the example code in MSDN Quote "These Patriot playoff wins are like Ray Charles songs, Nantucket sunsets, and hot fudge sundaes. Each one is better than the last." - Dan Shaughnessy
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.