Pointers and functions

Started by
2 comments, last by guyaton 20 years ago
What I am trying to do is send a pointer in a function, and inside that function create that pointer of some size (which can only be determined inside the function) and then store information to that pointer. When I exit the function I want to be able to access/use that information. How do I do that? ~Guyaton
~guyaton
Advertisement
function_name( data_type** ptr )

OR

function_name( data_type*& ptr )
That was much simpler that I was trying to do! thnx!



~Guyaton
~guyaton
I''ll just butt in and recommend the latter form:
function_name( data_type*& ptr)
because it forces the pointer itself to be a valid variable (though it does not necessarily point to something valid!). If you use data_type**, it''ll force you to do another NULL check.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement