This might be a trivial C++ semantics question, I guess, but I'm running into issues on Windows (VS2010) with this. I have a class as follows:
class A {
public:
some_type some_func();
private:
struct impl;
boost::scoped_ptr<impl> p_impl;
}
I'd like to access the function some_func
from within a function defined in the struct impl
like so:
struct A::impl {
impl(..) {} //some constructor
...
some_impl_type some_impl_func() {
some_type x = some_func(); //-Need to access some_func() here like this
}
};
The VS 2010 contextual menu shows an error so didn't bother building yet:
Error: A non-static member reference must relative to a specific object
I'd be surprised if there was no way to get to the public member function. Any ideas on how to get around this are appreciated. Thanks!
You need an instance of
A
.A::impl
is a different struct thanA
, so the implicitthis
is not the right instance. Pass one in in the constructor: