Advertisement

Accesing private data...

Started by July 26, 2000 03:10 PM
2 comments, last by Grugnorr 24 years, 4 months ago
In my DirectDraw wrapper I need to access to the direction of a private data from another class...Let me explain: I have a CDirectSurface class with a private variable,_lpdds, that is a LPDIRECTDRAWSURFACE4 I return with Get(). When I try to create the primary surface I need its direction: something like this: & _lpddsfront->Get()...Which is not legal because & needs a left value... What can I do?.I´m new at Object Oriented Programming but I think I have done well with setting the surface itself as private, so I don´t want to make it public as CDX does... The other soluction I´ve think of is creating the front and back buffers in CDirectSurface, by calling a method of it... The problem in my way is that with the return statement you get a copy of what you return, not the variable itself... What the hells!
What the hells!
OK, provided I''m understanding you correctly, it sounds like you''re Get() function will return a pointer to the proper surface. That''s fine.

So I think all you''ll have to do is use some parentheses:

&(_lpddsfront->Get());

Wait...why are you passing the address of a pointer? ''LP'' means Long Pointer...can you just pass it as it is?

Vyvyan
Advertisement
if your Get() function returns an LPDIRECTDRAWSURFACE, that IS a pointer.
I think you could redefine your Get() function as returning a
LPDIRECTDRAWSURFACE4 &
something like
class CDirectSurface
{
.
.
.
LPDIRECTDRAWSURFACE4 & Get();
.
.
.
};

This topic is closed to new replies.

Advertisement