手机下载视频网站模板下载wordpress pdf缩略图不显示
手机下载视频网站模板下载,wordpress pdf缩略图不显示,iis7 网站 目录,网上手机商城网站建设老子什么时候能找到一个很爱我还和我一样喜欢看日出日落的对象
一#xff0c;引用
给变量起别名#xff0c;数据类型 别名原名#xff1b;引用一定要初始化#xff0c;初始化之后不能更改
#include iostream
using namespace std;
int main()
{int a 10;i…老子什么时候能找到一个很爱我还和我一样喜欢看日出日落的对象
一引用
给变量起别名数据类型 别名原名引用一定要初始化初始化之后不能更改
#include iostream
using namespace std;
int main()
{int a 10;int b a;//一定要初始化是不能intbcout a endl;cout b endl;b 99;cout a endl;cout b endl;a 4445;cout a endl;cout b endl;int c 20;b c;cout a endl;cout b endl;cout c endl;c 888;cout a endl;cout b endl;cout c endl;return 0;system(pause);
}
1.1 引用做函数参数——形参会修饰实参
#include iostream
using namespace std;
void swap(int a, int b)
{a b;b a - b;a - b;cout a endl;cout b endl;
}
int main()
{int a 111;int b 666;int aa a;int bb b;swap(aa, bb);cout a endl;cout b endl;return 0;system(pause);
}
1.2 引用做函数返回值
不要返回局部变量的引用/指针【栈区会被释放】函数的调用可以作为左值
#include iostream
using namespace std;
int swap(int a, int b)//返回引用视作返回地址/指针
{//static int c a b;非常量应用的初始值必须做左值//int sum a b;//静态变量全局区程序结束系统释放//static int c sum;//不对静态引用什么鬼哈哈哈哈哈哈哈地址指向的还是局部变量static int sum a b;int c sum;return sum;
}
int main()
{int a 111;int b 666;int aa a;int bb b;int c swap(aa, bb);//C是这个函数返回值的引用且不可更改cout a endl;cout b endl;cout endl;cout c endl;cout c endl;cout endl;swap(aa, bb) 10000;//左值//给函数赋值-给C赋值cout c endl;cout c endl;return 0;system(pause);
}
1.3 本质——指针常量
乐记不住专用术语系列。int aint *const p差别就是引用看不到过程
1.4 常量引用
变量传入函数可以用引用的方式接受
#include iostream
using namespace std;
void showvalue(/*const*/ int val)//防修改
{cout val endl;val 100;
}
int main()
{int a 10;const int c 10;//引用必须是一块合法的空间这里编译器将代码修改为int temp10;【一个零时变量】const intctemp//c23;//const了哦showvalue(a);//变量传入函数用引用的方式接受cout a endl;return 0;system(pause);
}
二函数提高
2.1 函数默认参数
返回值类型 函数名 参数默认值{语句}形参可以有默认值
#include iostream
using namespace std;
int show(int a, int b 10, int c 30)
//如果某个位置已经有了默认参数那么从这个位置往后从左往右必须都有默认值
{return a b c;
}
int func(int a, int b);//声明和函数只要一个有默认参数
int func(int a 190, int b 10)
{return a b;
}
int main()
{cout show(20) endl;cout show(20,20) endl;//覆盖默认值//cout show(20, ,20) endl;语法错误cout show(20,20,40) endl;cout endl;cout func() endl;return 0;system(pause);
}
2.2 函数占位参数
返回类型 函数名 函数类型/INT{ }占位调用函数时须填补该位置
#include iostream
using namespace std;int func(int a , int )
{return a ;
}
int func2(int a, int 10)//占位参数可以有默认值
{return a;
}
//int func1(int a 190, int)不可以
//{
// return a;
//}
int main()
{//cout func1(1) endl;//cout func1(1,10) endl;//都不行cout func(1, 10) endl;//10拿不到cout func2(1, 10) endl;return 0;system(pause);
}
2.3 函数重载
作用函数名可以相同 条件同一作用域函数名称相同函数参数类型 || 个数 || 顺序 不同类型不同 *函数的返回值不可以作为函数重载的条件
#include iostream
using namespace std;void func()
{cout 函数调用 endl;
}
void func(int a)
{cout 函数调用(int a) endl;
}
void func(double b)
{cout 函数调用(double b) endl;
}
void func(int a,double b)
{cout 函数调用(int a,double b) endl;
}
void func(double b,int a)
{cout 函数调用(double b,int a) endl;
}
void func(int a,int b)
{cout 函数调用(int a,int b) endl;
}//void func( int b, int a)
//{
// cout 函数调用( int b, int a) endl;
//}不行
//int func(int a, int b)
//{
// cout 函数调用(int a,int b) endl;
//}不行int main()
{func();func(10);func(2.3);func(10, 10);func(10, 3.4);func(3.4, 10);return 0;system(pause);
}
2.4 函数重载注意事项
引用作为重载条件原来值传递就是真的进行了一次赋值操作乐懂了 重载函数遇到默认参数保证【函数名参数】只能启动一个函数
#include iostream
using namespace std;void func(int a)//int a10//不合法
{cout 函数调用(int a) endl;
}
void func(const int a)//const inta10合法
{cout 函数调用(const int a) endl;
}//以下都不可以和 void func(int a)一起
//void func(const int a)
//{
// cout 函数调用(const int a) endl;
//}不行//void func(int a)
//{
// cout 函数调用(int a) endl;
//}对重载函数的调用不明确不行void func2(int a, int b 10)
{cout 函数调用(int a, int b 10) endl;
}
void func2(int a)
{cout 函数调用(int a)_--2 endl;
}
int main()
{int a 10;func(a);func(10);const int b 90;func(b);func2(10, 20);//func2(10);不行return 0;system(pause);
}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/89971.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!