DirectDraw in a class

Started by
15 comments, last by vbisme 22 years, 5 months ago
If I take out the "static" it compile fine.
Advertisement
You have the static member declared in the header file, but it doesn''t exist anywhere. You need to add a line like this in the cpp file for the class:

LPDIRECTDRAW7 DDWrapper::lpDD;

etc...
if the static is in the header ,
you have to declare it in the cpp also .

    //a.h  class a  {     static int b;   }  //a.cpp   int a::b = 0;  


if not you will get linker errors..




{ Stating the obvious never helped any situation !! }
It works, but for knowledge sake: What is really the effect of declare class member as static?
Inside a class, static makes a property global to that class.
Since it''s static (ie class-global) it needs to be allocated outside a class instance. The declaration (the part in the cpp file) creates this storage space.

Magmai Kai Holmlor
- Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

You can also say that a static member belongs to the class and a non-static member belongs to the object.

You only want ONE LPDIRECTDRAW pointer so if you use inheritance it needs to be static, other wise every class you derive from the base class will have it''s own LPDIRECTDRAW pointer which is not what you want, therefor at least make the LPDIRECTDRAW pointer static.

I also made my members in the base class protected so you could only get to them by deriving from the baseclass, otherwise one could use DD_Base::pDD anywhere in the program.
C++, C++, C++
quote:Original post by Oluseyi
Original post by Warden
Since we''re working on porting ot other systems besides windows…

"..we really shouldn''t use a platform-specific API where possible."


True, but since I''m actually doing it only to learn all the different APIs…..

And it also helps us think about what we might want to do in projects were portability or large key variable exchange is nessicary, or even dynamic data exchange (wouldn''t that be neet!?) Anyway…. yeah, just thought I''d explain myself

-Warden
-Warden

This topic is closed to new replies.

Advertisement