|
-
September 3rd, 2009, 02:26 PM
#16
Re: Pointer Problem
 Originally Posted by Holloweye
I fixed the things you told me jefranki.
I tried with this:
if(*binarys[*binaryid]->ExpressionPointer1 == NULL)
Now I get this error:
Code:
.... c:\users\christer\desktop\projects\expressionparser\expressionparser\binaryexpression.h(8) : see declaration of 'Binary'
1> did you intend to use '.' instead?
....
1>ExpressionParser - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
From what you posted earlier: Binary binarys[99]; This means you defined binarys as an array of Binary objects.
Where you may be getting confused when the technical detail gets mentioned that binarys or any other array names are pointers. Yes, that's true. But as soon as you get an index using the brackets (i.e. binarys[binaryid]), you get an object back, not a pointer.
If you do *binarys you get the first object in the array back, which is not what you want. This will also prevent use of the brackets. So ditch the first * .
The -> operator is used with pointers. So this is also not what you want. Use the simple . (dot) operator.
Assuming you changed this to the pass-by-reference I mentioned, that means you no longer should use the * with binaryid in your reader function. (Pass-by-reference means you are working with the same variable/object you passed in, not a copy)
The net result is:
Code:
if(binarys[binaryid].ExpressionPointer1 == NULL)
If you didn't use pass by reference, you have:
Code:
if(binarys[*binaryid].ExpressionPointer1 == NULL)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|