Re: Errors with ->*
Aniruddha Bhattacharyya <[email protected]> Tue, 2 Aug 2011 22:25:27 +0530
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <CAOXuEswGDy+td6XN9e-NDmuLNs1SYttRJgkMKFK=F+f4GCob0w@mail.gmail.com> |
typo correction :
(*aptr).xptr = 5;
On Tue, Aug 2, 2011 at 10:24 PM, Aniruddha Bhattacharyya
<[email protected]> wrote:
> 1) a .* xptr = 3 ;
> Above line's syntax is wrong.
> Should be
> *a.xptr = 3;
>
> 2) Also declare the structure member variables as
> int *xptr, *yptr ; (otherwise yptr will be of type int, not of int*)
>
>
> 3) aptr ->* xptr = 5 ;
> is also of wrong syntax.
> Should be
> *aptr->xptr = 5 ;
>
> Which is equivalent to
> *(aptr->xptr) = 5;
>
>
>
> the above code DOES NOT mean this one :
>
> (*aptr)->xptr // this one dereference aptr first, then
> does nothing to xptr
>
>
>
> Thanks.
>
> On Tue, Aug 2, 2011 at 10:01 PM, Shriramana Sharma <[email protected]> wrote:
>>
>> Hello -- long time since I posted on this list.
>>
>> I'm trying to understand the use of ->* but in compiling the attached program which I thought was straightforward I am getting the following errors:
>>
>> foo.cpp: In constructor ‘mystruct::mystruct()’:
>> foo.cpp:9:12: error: invalid conversion from ‘int*’ to ‘int’
>> foo.cpp: In function ‘int main()’:
>> foo.cpp:21:7: error: ‘xptr’ was not declared in this scope
>> foo.cpp:22:7: error: ‘yptr’ was not declared in this scope
>>
>> Please help.
>>
>> --
>> Shriramana Sharma
>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html