DirectDraw in a class
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...
LPDIRECTDRAW7 DDWrapper::lpDD;
etc...
if the static is in the header ,
you have to declare it in the cpp also .
if not you will get linker errors..
{ Stating the obvious never helped any situation !! }
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
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
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.
quote:Original post by OluseyiOriginal 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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement