TCPL_4 types and declarations

4.1 types

consider x=y+f(2); For this to make sense in a c++ program, the names x, y, and f must be suitably declared. That is, the programmer must specify that entities named x, y, and f exit and that they are of types for which =(assignment), +(addition), and()(function call), respectively, are meaningful.

c++程序中出现的名字在使用之前必须被合理的声明,就是说,程序员必须指定实体x, y, f,是存在的,并且这三个实体的类型具有这样的特点,当赋值操作,加操作,函数调用操作作用在这些类型的对象上时,这些操作是有意义的。

Every name(identifier) in a c++ program has a type associated with it. This type determines what operations can be applied to the name(that is, to the entity referred to by the name) and how such operations are interpreted.

float x;       // x is a floating-point variable

int y;          // y is an integer variable with the initial value 7

float f(int); // f is a function taking an argument of type int and returning a floating-point number

would make the example meaningful.(将能使x=y+f(2);有意义),顺便说一下,我觉得赋值操作符,加操作符,实际上都是函数,针对于自定义类型时,我们重载操作符,不也是把这些操作符来当作函数来处理的么,扩展一上,最好不要把操作符与变量之间加上空格,那样好像是把函数与参数分开了定一样不好。

4.1.1 fundamental types

c++ has a set of fundamental types corresponding to the most

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值