I have class B and class A. In method of class B (let name it foo()) I have defined local object of class A. In class A I have method taking B object. How to pass B object to this method of class A when A object is local in method of class B. ?
class B {
public:
void foo()
{
A a;
a.bar(???); // want to pass B object?
}
};
class A {
public:
void bar(B& b)
{
...
}
};
If you want to pass the current instance of
B:If you want a different instance:
If you want to pass a temporary, you need to modify
A::footo:and then directly pass it: