PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

C++ Help

I'm now one week into C++ and need help. I'm playing with GAPIDRAW trying to add sound. My problem is this whole class business and variable declarations. Here's the code:

CWave * m_cWave;
m_cWave = new CWave( );

DWORD m_dwSysVolume = m_cWave->getVolume( );
m_cWave->setVolume(0x71C471C4);
m_cWave->playResourceWav(hInst, IDR_WAVE, false);

This works from within WinMain. If I use m_cWave from within the GAPIDRAW functions I recieve m_cWave' : undeclared identifier. I'm sure this is basic C++ stuff that's why I posted here instead of the GAPIDRAW forum.

Please forgive my newbieness.
You need to include the header that defines the CWave class. Probably gapidraw.h or something like that.

Dan East
Dan,
Are you saying I need to define the cWave class in the GapiDraw.h. It's not part of GapiDraw, I'm defining it in my main *.cpp, using function prototypes from MMSYSTEM.H. But the "object?" m_cWave is undeclared when referenced in the GapiDraw class. Do I need to make it global, static or somthing? Or make it a subclass of the GapiDraw class. Sorry if I'm using the wrong terms.


class CWave
{
public:

CWave();
~CWave();

BOOL playResourceWav(HINSTANCE hInst, DWORD dwSoundID, BOOL bWait);
void setVolume(DWORD dwVolume);
DWORD getVolume();
};

etc...

Thank,
Brian
You need to provide the prototype for the class in a header file, so you can include it in other source files.

This:
class CWave
{
stuff deleted
};

should go into a .h file. Include that file in any cpp that uses that class.

Dan East
That worked. Thanks Dan!