Don't worry so much about the thread-safety. I know what I'm doing there, and things will be thread-safe. I'm a semi-competent programmer who went on a bit of a hiatus so things are a bit rusty.
So it turns out my example wasn't exactly as I remembered it (just took a look at the code again) and what I'm trying isn't compiling. So let's try this again...
Code:
#include <iostream>
class A;
class B {
public:
void setA1(int A1);
void copy(void);
void print(void);
private:
A a1, a2;
};
class A {
public:
friend void B::copy(void);
friend void B::setA1(int A1);
friend void B::print(void);
private:
int _a;
};
void B::setA1(int A1)
{
a1._a = A1;
}
void B::copy(void)
{
a2._a = a1._a;
}
void B::print(void)
{
std::cout<<a1._a<<" "<<a2._a<<std::endl;
}
int main(void){
B b;
b.setA1(5);
b.copy();
b.print();
std::cin.get();
return 0;
}
Again doesn't compile. What's the general "rule" here to indicate to the compiler a lack of infinite recursion.