Connecting Tech Pros Worldwide Forums | Help | Site Map

why "." and "->" operators ?

Guest
 
Posts: n/a
#1: Jul 22 '05
I used to remember why c++ needed both.

For example

class A{

f();

};



A* aa;



You could do either "aa->f()" or "(*aa).f()". So why does C++ need both
operators.



Raj



JKop
Guest
 
Posts: n/a
#2: Jul 22 '05

re: why "." and "->" operators ?


posted:
[color=blue]
> I used to remember why c++ needed both.
>
> For example
>
> class A{
>
> f();
>
> };
>
>
>
> A* aa;
>
>
>
> You could do either "aa->f()" or "(*aa).f()". So why does C++ need both
> operators.
>
>
>
> Raj[/color]


It doesn't, just as we humans don't need tea or coffee.

-JKop
Till Crueger
Guest
 
Posts: n/a
#3: Jul 22 '05

re: why "." and "->" operators ?


On Wed, 23 Jun 2004 15:53:48 +0000, rajkuma wrote:
[color=blue]
> You could do either "aa->f()" or "(*aa).f()". So why does C++ need both
> operators.[/color]

True... and instead of doing a+b you could do a-(-b) or even a-(0-b) and
get rid of the + operator... Or of the * operator.. Or almost everything
else until you are left with a turing tarpit.
Till


--
Please add "Salt and Peper" to the subject line to bypass my spam filter

Closed Thread