This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: What's the difference between (*(x)).a and (x)->a
- From: "John (Eljay) Love-Jensen" <eljay at adobe dot com>
- To: John Fine <johnsfine at verizon dot net>
- Cc: GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 21 Jan 2009 06:17:54 -0800
- Subject: Re: What's the difference between (*(x)).a and (x)->a
Hi John,
> Can they be different in C++ ?
>
> A key phrase in the question is "x is an expression which generates a
> struct pointer."
>
> You can overload the meaning of * or -> if x is a struct. I thought you
> couldn't overload them if x is a pointer.
I can't think of any way of overloading operations on a pointer -- struct
pointer or any other sort of pointer. All pointers are POD.
I can think of many ways of overloading operations on an object. Smart
pointers (e.g., std::auto_ptr) are really objects with pointer semantics.
I think you are correct. Good eye and very careful reading... good catch!
Sincerely,
--Eljay