| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"nifsmith" |
| Date: |
19 Oct 2004 04:08:32 AM |
| Object: |
Dereferencing pointers |
Is
*(pointer1->pointer2)
The same as
(*(*pointer1).pointer2)
TYIA
nifsmith
.
|
|
| User: "Sharad Kala" |
|
| Title: Re: Dereferencing pointers |
19 Oct 2004 04:21:54 AM |
|
|
"nifsmith" <hawklord451@lycos.co.uk> wrote in message
Is
*(pointer1->pointer2)
The same as
(*(*pointer1).pointer2)
Yes.
Section 5.2.5 paragraph 3 - "If E1 has the type ``pointer to class X,'' then
the expression E1->E2 is converted to the equivalent form (*(E1)).E2;"
Sharad
.
|
|
|
|
| User: "John Harrison" |
|
| Title: Re: Dereferencing pointers |
19 Oct 2004 04:13:37 AM |
|
|
"nifsmith" <hawklord451@lycos.co.uk> wrote in message
news:cl2lif$5lc$1@sparta.btinternet.com...
Is
*(pointer1->pointer2)
The same as
(*(*pointer1).pointer2)
TYIA
nifsmith
Yes.
john
.
|
|
|
|
| User: "JKop" |
|
| Title: Re: Dereferencing pointers |
19 Oct 2004 04:25:11 AM |
|
|
nifsmith posted:
Is
*(pointer1->pointer2)
The same as
(*(*pointer1).pointer2)
TYIA
nifsmith
Yes, it is for *pointers*.
Note however, that for acutal objects, it doesn't always hold true.
For instance:
struct Monkey
{
int* tail;
};
class Blah
{
public:
Monkey a;
Monkey b;
Monkey& operator*()
{
return a;
}
Monkey& operator->()
{
return b;
}
};
int main()
{
Blah poo;
int k;
*( poo->tai l) = &k;
*( (*poo).tail ) = &k;
}
In that above, the statements do two totally different things, ie. there's
two different "tail"s!
(Actually now as I'm writing this, I'm not 100% sure that you can overload
->)
-JKop
.
|
|
|
| User: "Catalin Pitis" |
|
| Title: Re: Dereferencing pointers |
19 Oct 2004 04:27:03 AM |
|
|
"JKop" <NULL@NULL.NULL> wrote in message
news:X35dd.39469$Z14.13988@news.indigo.ie...
[...]
(Actually now as I'm writing this, I'm not 100% sure that you can overload
->)
Yes you can
Catalin
.
|
|
|
| User: "JKop" |
|
| Title: Re: Dereferencing pointers |
19 Oct 2004 04:29:56 AM |
|
|
Catalin Pitis posted:
"JKop" <NULL@NULL.NULL> wrote in message
news:X35dd.39469$Z14.13988@news.indigo.ie...
[...]
(Actually now as I'm writing this, I'm not 100% sure that you can
overload ->)
Yes you can
Catalin
This pleases me!
( C++, 1 point, *****, 0 points )
-JKop
.
|
|
|
| User: "Brian Riis" |
|
| Title: Re: Dereferencing pointers |
19 Oct 2004 10:03:10 AM |
|
|
JKop wrote:
Catalin Pitis posted:
"JKop" <NULL@NULL.NULL> wrote in message
news:X35dd.39469$Z14.13988@news.indigo.ie...
[...]
(Actually now as I'm writing this, I'm not 100% sure that you can
overload ->)
Yes you can
Catalin
This pleases me!
It should! :) That would be how smart pointers work...
(Well.. part of it.)
--
/Brian Riis
.
|
|
|
|
|
|
|

|
Related Articles |
|
|