-
void fun(int i,int j = 5 ,int k = 10); void fun(int i ,int j ,int k) 这样编译不会报错查看全部
-
const(控制变量是否可以变化) const int x=3;(则此时x为常量,不可进行再赋值) const与指针类型 const int *p=NULL; int const *p=NULL;(两种写法完全等价) int *const p=NULL; const int *const p=NULL; int const *const p=NULL;(这两种写法也是完全等价的) int x=3; const int *p=&x; *p=4(错误,因为const指定的为*p);p=&y;(正确) int x=3; const int *const p=&x; p=&y(错误,因为const指向的为p,只能为x的地址) const与引用 int x=3;const int &y=x; y=10(错误,y通过const限定只能为x的别名,值为3) 总结: const int x=3;int *y=&x;(这种写法是错误的因为x本身定义为const,在用一个可变的指针指向,那么就有用指针改变x值得风险,这是系统所不允许的); int x=3; const int *y=&x;(正确,这样保证了指针对x只有可读性,而没有可写性)查看全部
-
int *p = &a; int *&q = p; *q = 20;查看全部
-
const &z=x; z为x的引用 加const修饰 z变为常量不能再给z赋值查看全部
-
*const p=&x; p变成了常量 p就不能再指向y 但可以给*p赋值查看全部
-
const *p=&x; p还能指向y查看全部
-
上错下对查看全部
-
#include<iostream> using namespace std; int getMax(int a, int b) { return a>b ? a:b; } int getMax(int *arr; int count) { int maxNum=arr[0]; for (int i =1; i<count; i++) { if(maxNum<arr[i]) { maxNum=arr[i]; } } return maxNum; } int main() { int numArr[3]={3, 8, 6}; cout<<getMax(numArr,3)<<endl; cout<<getMax(numArr[0],numArr[2])<<endl; return 0; }查看全部
-
const查看全部
-
C C++中内存申请与释放 C{ malloc free },C++{new delete} int *p = new int[100]; | int *p = new int; | int *p; delete []p; | delete p; | p = (int *) malloc(sizeof(int)); p = NULL; | p = NULL; | free(p);查看全部
-
函数默认参数, 有什么用呢?查看全部
-
````查看全部
-
申请与释放内存查看全部
-
```查看全部
-
strcpy(s1,s2);strcpy函数的意思是:把字符串s2中的内容copy到s1中,连字符串结束标志也一起copy查看全部
举报
0/150
提交
取消