Sorry
C#
does not provide the
friend
keyword (see
here[
^]). As suggested there, you might replace the
private
keyword with the
internal
one (if your class is in the same assembly).
[Update]
Probably I missed the C++
tag:
C++
has the
friend
keyword (see
here[
^] for sample code), you may use it.
My silly code sample:
#include <iostream>
using namespace std;
class Derived;
class Base
{
friend class Derived; int b;
public:
Base(int b=0):b(b){}
void show(){ cout << "b = " << b << endl;}
};
class Derived: public Base
{
public:
Derived(){}
void inc(){b++;} };
int main()
{
Derived d;
d.inc();
d.inc();
d.show();
}
[/Update]