Archived

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

a few questions

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all I just have a few questions: 1) What is an HRESULT? I know its some kind of return value but what does it do? 2) How do you use the thing? I see this thing everywhere but I have no idea how to use it or what exactly it does? 3) Why use dynamic data? Mainly: Why do blah = new Cblah; instead of Cblah blah; Thanks. -Darkzim

Share this post


Link to post
Share on other sites
Don''t remember exactly what an HRESULT is- I think it''s just a typedef for an unsigned int. At any rate, it''s just a fancy name for an ordinary value.

As far as question 3, there are lots of places to use dynamic data. Generally, whenever you don''t know how big something is before the program runs. Whenever you load files (like say images or sounds), you will probably have to allocate them dynamically. There are lots of possibilities.

For your example, using:

blah = new Cblah;
instead of
Cblah blah;

I assume that you''re talking about in a function.. well in the second case, "Cblah blah", that means a thing called blah is created on the stack, and that it will be automatically killed at the end of the function. If you want to make something that lasts longer than the function, you would need to use the first one.

Share this post


Link to post
Share on other sites
quote:
Original post by pinacolada
I assume that you''re talking about in a function.. well in the second case, "Cblah blah", that means a thing called blah is created on the stack, and that it will be automatically killed at the end of the function. If you want to make something that lasts longer than the function, you would need to use the first one.


thanks...that was a helpful explanation for me even. i am struggling learning arrays & pointer right now, and these can invovle static and dynamic memory. this explanation is really useful

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
An HRESULT is just a type used by the Windows API to enumerate whether a function was successful or not. You''ll find in many DirectX/OGL programs, for example, many people use

if(FAILED(SomeInitFunctionThatReturnsAnHresult))

for error checking; the FAILED function checks the HRESULT that is returned by SomeInitFunctionThatReturnsAnHresult.

All of this is from the top of my head, so please correct me if I''m wrong.

-Brendan Bond

Share this post


Link to post
Share on other sites