Sat Dec 25

注意,以下声明是不同的哦

int *matrix[10]; // array of 10 pointers

int (*matrix)[10]; // pointer to an array of 10 ints

 

因为[]的优先级要比*的优先级高。

 

***************************************

***************************************

 

const 不能作为函数重载的差异。

例如:

int test( int t );

int test( const int t );

 

gcc 会报 “函数重定义”。

 

但应参与const 形参的等价性仅适用于  非引用形参

对于引用参数,指针参数,const能作为重载的差异。

 

注意: 不能给予指针本身是否为const来实现函数重载。

void f(int *);

void f(int *const); // redeclaration

 

 

***************************************

***************************************

 

函数的局部声明可以屏蔽其他的重载的函数声明。

对编译器的名称解析有重大影响。


 

***************************************

***************************************


重载确定的三个步骤
1,确定同名的函数中那些作用域可见的函数
2,通过实参确定可行函数。(a 形参个数与实参个数,b 实参类型与形参类型)
3,寻找最佳匹配 (类型精确>隐式转换)
1 精确匹配
2 类型提升匹配
3 标准转换匹配
4 类类型转换匹配

***************************************

***************************************


函数指针类型
typedef int (*pf)(int, int);
pf ff(int); //return to a pointer of function

函数类型
typedef int f(int, int);
f *ff(int); // return to a pointer of function

***************************************

***************************************

argument is different from parameter.
argument is the value (R) passed into the function.
parameter is the value (L) variable defined to accept the argument's value.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值