I have two Class A, B.
For A, I have two method callB(), and checksomethinginB().
For B, I have one method execute().
I use them like:
A _a;
_a.callB(); //inside the function, B object _b will be created
//after _b created, in another place, _b will execute _b.execute().
_b.execute()
{
// I want to use A method checksomethinginB()
}
So I don’t know a good way to use A method in B, what I can create is to use static functions, but I think there maybe better way, thanks for your suggestion!!
Either pass the correct instance of
Ato the constructor ofB, or pass it along whenever needed.If
checksomethinginBdoesn’t need any state inAthen it can be static of course.