friend funcation problem in VS 2008

"cannot access private member declared in class"
its probelm related to friend function and i m use only one firend funcation and its run in vS2003 but not in VS 2008

class CP;
friend BOOL CIP::SDP(BOOL bDStaee);


CP,CIP both are class name class and SDP is Method which we want as friend.
=====================================================

pise of code :
we want CP class mthod SDP is friend of CIP class.



// first file

class CPI : public CWnd
{
public :
friend BOOL CIP::SDP(BOOL bDraftPrintState);
// THis line show the error
}

//another file

class CPI;

class CIP: public CSDChildWnd
{
private:
BOOL SDP(BOOL bDraftPrintState);
}
BOOL CIP::SDP(BOOL bDraftPrintState)
{
//CPI::sm_bDraftPrintState = bDraftPrintState;
return TRUE;
}

Last edited on
I have never coded anything with friends, but my guess is that you cannot say "I (class CP) am friends with the method CIP::SDP, even though that method is private and I shouldn't even know it exists.".

My guess is that it will work if you make CIP::SDP() public.
Topic archived. No new replies allowed.