I've been asked to define Point, Player and Bullet.
I think i had defined player and bullet. But im stuck how do i (DEFINE) pointer.
where does it go?
how would i write it?
can i use a point to point to a class?
OR is it used to point to a function?
how do i write a point as code.
i currently have player health and bullet colour, would i use a point to point to both of those functions and call the points through couts?
Im sorry i am very crap at trying to explain stuff. Hopefully this helps a little.
I've been asked to define Point, Player and Bullet.
Are you referring to a pointer or as class called "Point"?
You use the word "point". A point and a pointer are two different things.
Programming requires exactness. If you mean pointer, then you need to use that word. You can't use point and pointer interchangably.
I am still new to c++ only been a 3 months or so of my course sorry.
I believe i mean pointer/
I have looked at that c++ tutoral and didnt really understand it.I work better with examples.
//"An" idea:
//Pointer variables point to addresses of real variables(intention: data).
//This is my integer variable, set to 0
int myInteger = 0;
//This is my Pointer variable, of type int, pointing to address Null; hopefully nothing's there ;D
int *myPointerToInt = 0;//This is how a pointer is declared!
//I am assigning my Pointer the address of myInteger (& = address/[de]reference)
myPointerToInt = &myInteger;
//I can manipulate my integer variable:
myInteger = 5;//By direct variable access.
*myPointerToInt = 7;//by pointer variable access
//(Hint: An (*) asterisk before pointers refers to their value, not address)
/*
Why should you use a pointer? Not sure, it is up to you.
Personally I use them to alias data and sometimes I'll include them to allow possible expansion of data.
They can be used as place holders for data that does not already exist.
You will definitely find folks using it in trees.
*/
Many more.... Times up.
Have a good day.
Tip: Read the tutorial, it'll explain uses with functions, objects and such; there is little reason to restate what's already stated; though I just sort of did that...