Bad pointers.

Started by
1 comment, last by Dko 18 years, 4 months ago
I was wondering if someone could help me work out this error im getting when I try to compile my code. Ive never been very good with the complexitys of pointers. Though I understand what they are well enough. I just can't tell what im monkeying up. So I get this error error C2664: 'void Bitmap::Draw(SDL_Surface *,int,int)' : cannot convert parameter 1 from 'SDL_Surface *(void)' to 'SDL_Surface *' Im using my function Bitmap::Draw like this. BmpTest.Draw(_pGame->GetScreen, 0, 0); The code for it is void Bitmap::Draw(SDL_Surface *screen, int x, int y) { //Lets draw our bitmap to screen. Yay ^^ SDL_Rect dest; dest.x = x; dest.y = y; SDL_BlitSurface(m_SufBitmap, NULL, screen, &dest); } GetScreen basically is saposta send the revelent SDL screen info to the function and this is how I have it. SDL_Surface * GetScreen() { return m_pScreen; }; // m_pScreen is a pointer I don't know what I have wrong here. It just confuses me to no end trying to remmber all the specifics on how to use Pointers. When I have to use a * or a & and what not. T_T Please help as my book on C++ is none.
Advertisement
Hi,

BmpTest.Draw(_pGame->GetScreen, 0, 0);

should be

BmpTest.Draw(_pGame->GetScreen(), 0, 0);

in the first case you gave a pointer to a function, while you wanted to give the parameter returned from that function.

Some help to:

int* pInt; //pointer to an int variableint i;pInt = &i; // get the address of the int variable (where it is in memory) and asign that to the pointer (so the pointer knows where to point to)int i2 = *pInt; // get the value this pointer points to.


Hope this helps.
“Always programm as if the person who will be maintaining your program is a violent psychopath that knows where you live”
Gehh me and stupid mistakes. >.< Thanks for the help. Now im getting lots of run time errors though like.

Unhandled exception at 0x00411b48 in JPong.exe: 0xC0000005: Access violation reading location 0x00000008.

I have no clue how to deal with them as ive never got anything like them. >.o

EDIT: Never mind. Found out I was creating my bitmaps not using the file name but instead I had a variable in my code that was surrounded by quotes. Making it act as a string instead. ^^;

This topic is closed to new replies.

Advertisement