I have two classes. Class A and Class B.
I have a function in Class A that i would like to use in class B. I was thinking about passing a reference of Class A to the constructor of Class B and then call the function after that.
Would that work? Can someone show me an example?
Thanks in advance!
Yes, it will work. And it’s a decent way to do it. You just pass an instance of class A:
And then you can have: