为什么两个都有“。”和“ - >” ? [英] why have both "." and "->" ?

查看:62
本文介绍了为什么两个都有“。”和“ - >” ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经记得为什么c ++需要两者?

有人可以帮助我吗?


例如


A级{

f();

};


A * aa;


您可以执行aa> f()和或(* aa).f()。那么为什么C ++需要两个运算符呢。


Raj

I used to remember why c++ needed both ?
Could somebody help me here ?

For example

class A{
f();
};

A* aa;

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

Raj

推荐答案

" raj" < RA ****** @ hotmail.com> schreef in bericht

新闻:d7 ************************** @ posting.google.c om ...
"raj" <ra******@hotmail.com> schreef in bericht
news:d7**************************@posting.google.c om...
我曾经记得为什么c ++需要两者?
有人可以帮助我吗?

例如

A类{
f();
};

A * aa;

你可以做aa> f()和或(* aa).f()。那么为什么C ++需要两个
运算符。
Raj
I used to remember why c++ needed both ?
Could somebody help me here ?

For example

class A{
f();
};

A* aa;

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




我认为如果xxxx是xxxx,则使用xxxx-> yyyy一个指针

到一个对象/类和xxxx.yyyyy如果xxxx是对象/类



There is a difference I believe that xxxx->yyyy is used if xxxx is a pointer
to an object/class and xxxx.yyyyy if xxxx is the object/classs


> A级{
f();
};

A * aa;

你可以做aa> ; f()的"或(* aa).f()。那么为什么C ++需要两个操作符。
f();
};

A* aa;

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



恕我直言,这只是方便。


再见,Marco


raj写道:

你可以做aa> f()和或(* aa).f()。那么为什么C ++需要两个
运算符。

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




第二种形式涉及更多打字,需要更多努力才能阅读。


-

Russell Hanneken
eu ******* @ cbobk .pbz

使用ROT13解码我的电子邮件地址。



The second form involves more typing and requires more effort to read.

--
Russell Hanneken
eu*******@cbobk.pbz
Use ROT13 to decode my email address.


这篇关于为什么两个都有“。”和“ - &gt;” ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆