simple c++ question???
-
do anyone know how to write a copy of a pointer where the copy cant change what the original pointer is pointing to kinda like using call by value or call by constant reference but using pointers. i am having trouble doing this because if i make it constant, I cant change it, i can use reference but because the whole program is implemented with pointers i wont be able to use it. do anyone know how to get around this problem??? ex. int CComputer::CheckForMove(const CBoard* pBoard, int depth) but by doing this i cant call most of the function that would change the board because that would give me a syntax error... i wanted to used CheckForMove(const CBoard& rBoard, int depth) but i wont be able to use it because my whole program is done using pointers... anyways, thank you for your help... :)
-
do anyone know how to write a copy of a pointer where the copy cant change what the original pointer is pointing to kinda like using call by value or call by constant reference but using pointers. i am having trouble doing this because if i make it constant, I cant change it, i can use reference but because the whole program is implemented with pointers i wont be able to use it. do anyone know how to get around this problem??? ex. int CComputer::CheckForMove(const CBoard* pBoard, int depth) but by doing this i cant call most of the function that would change the board because that would give me a syntax error... i wanted to used CheckForMove(const CBoard& rBoard, int depth) but i wont be able to use it because my whole program is done using pointers... anyways, thank you for your help... :)
I *believe* the syntax is int * const pConstInt; Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
-
I *believe* the syntax is int * const pConstInt; Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
-
yah your right but is there way i can use pointer and not use reference to do my function... hey, christian thankx for the help :) :)
I don't understand ? If I do this: int * const pInt = new int; I can do this with no problems: *pInt = 5; because the value is not const. I cannot do this: pInt = new int; because the pointer *is*. Isn't that what you wanted ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
-
I don't understand ? If I do this: int * const pInt = new int; I can do this with no problems: *pInt = 5; because the value is not const. I cannot do this: pInt = new int; because the pointer *is*. Isn't that what you wanted ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little.