B
Bart Simpson
I'm quite puzzled by this. I have a class wrapped around a struct - a
ptr to which is sometimes needed by some legacy C code.
The ff sumamrizes the situation:
namespace { StructOfRawPtr nullstruct = {0} )
class WrappedPtr
{
public:
WrappedPtr:m_ptr(nullstruct){}
...
const rawPtr * RawPointer() const;
private:
rawPtr const * RawPointer();
StructOfRawPtr m_struct ;
}
//In other code
DoSomething(const rawPtr* p);
void foo(WrappedPtr& wrp)
{
//compiler complains cant access private member func for line below
DoSomething(wrp.RawPointer());
}
Why is the compiler trying to use the private function even thought the
signature of DoSomething() suggests that its the function that returns
the const rawPtr* that I need ?
ptr to which is sometimes needed by some legacy C code.
The ff sumamrizes the situation:
namespace { StructOfRawPtr nullstruct = {0} )
class WrappedPtr
{
public:
WrappedPtr:m_ptr(nullstruct){}
...
const rawPtr * RawPointer() const;
private:
rawPtr const * RawPointer();
StructOfRawPtr m_struct ;
}
//In other code
DoSomething(const rawPtr* p);
void foo(WrappedPtr& wrp)
{
//compiler complains cant access private member func for line below
DoSomething(wrp.RawPointer());
}
Why is the compiler trying to use the private function even thought the
signature of DoSomething() suggests that its the function that returns
the const rawPtr* that I need ?