#include<iostream>
using namespace std;
class B;
class A { public:
void UseClassB(B& test);
};
class B{
int a;
friend void A::UseClassB(B& test);
void privateSeta(int x){a=x;};
public:
void publicSeta(int x){a=x;};
};
void A::UseClassB(B& test){
cout<<test.a<<endl; }
int main() { A a; B b;
b.publicSeta(5);
B b2;
//b2.privateSeta(6) ; //....(*)
a.UseClassB(b);
return 0; }
1 Without using any setter method as in the code, just using the default compiler-generated constructor, how can I instantiate an object with an specific value of member a, say a=10. Is it possible or I am limited to instantiate one with some junk value?
2 Supposing I don't have publicSeta, how can I use privateSeta in the main function to actually set the value of member a? Is it even possible?