Jump to content
  • Advertisement
Sign in to follow this  
Dko

Bad pointers.

This topic is 4593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 variable
int 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.

Share this post


Link to post
Share on other sites
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. ^^;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!