April 12th, 2013, 08:45 PM
How to use HRESULT in C function ?
how can i write a function to return HRESULT, i Don't know what is HRESULT and how should it be used for, googled it and found that, HRESULT can be used to represent the error condition in our program, will not go deep it those bit values, but what i understood was
1. 0 or positive number indicates sucess
2. negative number will indicate failure
My Scenario, I have the following structure
Now I want to write a function
HRESULT TreeHasDepth(NODE* pNode, int depth)
// my code here
In above function,
1. if depth of tree is equal to the given value of depth passed
2. if depth of tree is greater than the given argument passed
3. if depth is less than the given value of integer passed
4. if the tree is null
For the above scenarios to be tested, probably we will have to override HRESULT, can someone help me to understand how can we do it ?
April 13th, 2013, 01:39 AM
Talk to your tutor and find out what they meant.
HRESULT is so widely used for so many things as to make it a useless idea without some context.
The best I could figure out would be
bool TreeHasDepth(NODE* pNode, int depth)
Which would return true if the tree is at least 'depth' levels deep at the given root node, or false otherwise.
Comments on this post
April 13th, 2013, 04:57 PM
According to the all knowing Wikipedia: HRESULT is most commonly associated with a particular kind of API return type used in OS/2 and Microsoft Windows (essentially an array of bit fields and codes). I wouldn't think a school assignment on data structures would prescribe such a thing. Take Salem's advice and ask your instructor to clarify exactly what an HRESULT is supposed to be.
I no longer wish to be associated with this site.