I want funcC3() to set and permanently change C1::a value, how to do it?
Declare it as friend function in C1:
class C1; //forward declaration
class C3
{
//...
void funcC3( C1& c);
};
class C1
{
//...
private:
int a;
friend void C3::funcC3( C1&);
};
void C3::funcC3( C1& c) { c.a = 100;}
I want global function gfunc() to be able to do the same, how?
Same as above:
class C1;
void gfunc( C1& c);
class C1 {
//...
private:
int a;
friend void gfunc( C1& c);
};
void gfunc( C1& c) { c.a = 100;}