Sign in to follow this  

Bad pointers.

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this