点(.)运算符和箭头(->)运算符的区别

 本机中,char类型数据占用1byte, unsigned int, int, long int, float类型的数据占用4 bytes, double类型的数据占用8bytes.

至于指向所有基本数据类型的指针(char*, int* , double*等)都是占用4bytes, 可以使用sizeof函数进行测量。

The<< operator on std::cout is overloaded. Its behavior depends on the type of the right operand.

The reason is that std::cout will treat a char* as a pointer to( the first character of) a C-style string and print it as such.

If you want to the address instead, you can just cast it to a pointer that isn't treated that way, something like:

cout<<(void*) terry; 或者cout<<(const void*) terry;

点运算符作用于对象,用于获取对象拥有的字段或方法。

箭头运算符作用于对象指针,先或者指针指向的对象,再隐式调用点运算符,获取对象拥有的字段或方法。

转载于:https://www.cnblogs.com/cbyzju/p/5244000.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值