Hello!
Please, can someone make me clear the construction a.side in next example? Does a not look like an object? But it is NOT an object, it is just an argument? Many thanks for any short&clear explanation!!!
Class A obviously "sees" into the class B, and gives to all objects of the class B the i (lets, say index) value the same: 10.
The program stopps at the line 19, when I try to create objects of the calss B, with attribute index. Pleas,e does someone see where is the error?
Many thanks!!!
class B {
friendclass A; // A sees into the B class
private:
int i;
};
class A {
public:
void a(B b);
};
void A::a(B b){
b.i=10;
}
int main(){
B obj1(2);
B obj2(3);
B obj3(4);
int z;
z=obj1.i;
cout<<z<<endl;
return 0;
}