a few questions
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
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.
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.
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
Thanks for responding so quickly. You did clear some stuff up.
Thakns again.
Anyone know about question 2?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement