#### Archived

This topic is now archived and is closed to further replies.

# stupid pointers

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

## Recommended Posts

ok, i have this peice of code here, what i want to do is be able to change the values of x, y, z from within the function. I know i can do this with points but i can't get it working. Could someone show me what i need to do? And i know i can make the routine much simpler but i have it this way because i need to modify xyz based on each step of the conditional statements. duckbob *code*
  bool colideroom(float x, float y, float z) { for (int i = 0; i <= NumBoxes - 1; i++) { if (room[i].Px >= x) { if(room[i].Nx <= x) { if (room[i].Pz >= y) { if(room[i].Nz <= y) { if (room[i].Py >= z) { if (room[i].Ny <= z) { return true; } } } } } } } return false; } 
[edit: added source tags] Edited by - Magmai Kai Holmlor on January 15, 2002 1:13:46 AM

##### Share on other sites
try this:

bool colideroom(float &x, float &y, float &z)

keep the rest the same. I hope that works im still somewhat a newbie.

Jeff D

Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton

##### Share on other sites
that worked, thanks

##### Share on other sites
Those are called references if you didn''t alraeyd know that. They work like pointers do, but use the non-pointer syntax (and can''t point to null).

##### Share on other sites
Pointers aren''t stupid, it''s the people that use that that are stupid (not talking about Duckbob, just making a statement

##### Share on other sites
i just have trouble with the concept, i understand that they are useful, and make things possible, but the first time i really learned programing (able to make somthing that did somthing useful) was in visual basic, which you don''t have to think about how it can be coded but only how it can be done

duckbob

##### Share on other sites
As I always teach - sarcastically - "Pointers are your friends!"

##### Share on other sites
Not criticising your coding style, but maybe you're not aware of the && operator?

  bool colideroom(float x, float y, float z){ for (int i = 0; i <= NumBoxes - 1; i++) { if ((room[i].Px >= x)&&(room[i].Nx <= x)&&(room[i].Pz >= y) &&(room[i].Nz <= y)&&(room[i].Py >= z)&&(room[i].Ny <= z)) { return true; } } return false;}

- seb

Edited by - bsxrider on January 15, 2002 7:26:01 PM

##### Share on other sites
did ya read my post, i have it like that for a reason, i know i can use the && operator, but once i got my problem fixed, which i did, i put operations between each step which is dependant on each step...progressivly, so in this instance i didn''t need to condence that in this instance

##### Share on other sites
Whoops sorry, I tend to just scan read a lot of the time

- seb

• 33
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631354
• Total Posts
2999491
×