How should I pass an object wrapping an API to a class using that API?
Posted
by Billy ONeal
on Stack Overflow
See other posts from Stack Overflow
or by Billy ONeal
Published on 2010-05-27T01:13:20Z
Indexed on
2010/05/27
1:21 UTC
Read the original article
Hit count: 719
Hello everyone :)
This is a revised/better written version of the question I asked earlier today -- that question is deleted now.
I have a project where I'm getting started with Google Mock. I have created a class, and that class calls functions whithin the Windows API. I've also created a wrapper class with virtual functions wrapping the Windows API, as described in the Google Mock CheatSheet. I'm confused however at how I should pass the wrapper into my class that uses that object. Obviously that object needs to be polymorphic, so I can't pass it by value, forcing me to pass a pointer. That in and of itself is not a problem, but I'm confused as to who should own the pointer to the class wrapping the API.
So... how should I pass the wrapper class into the real class to facilitate mocking?
© Stack Overflow or respective owner