Suppose I had a class named foo containing mostly data and class bar that's used to display the data. So if I have object instance of foo named foobar, how would I pass it into bar::display()? Something like void bar::display(foobar &test)?
Yes, almost. Or, if possible, use a const reference to signal that the method is not going to modify the object passed as an argument.
class A;
class B
{
// ...
void some_method(const A& obj)
{
obj.do_something();
}
// ...
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With