为了账号安全,请及时绑定邮箱和手机立即绑定
  • 有默认参数值的参数必须在参数表的最右端
    查看全部
    0 采集 收起 来源:[C++]函数特性

    2016-01-13

  • 引用作函数参数
    查看全部
    0 采集 收起 来源:C++语言引用

    2016-01-13

  • 引用可理解为别名
    查看全部
    0 采集 收起 来源:C++语言引用

    2016-01-13

  • 函数参数默认值
    查看全部
    0 采集 收起 来源:[C++]函数特性

    2016-01-13

  • 发烦烦烦烦烦烦烦
    查看全部
    0 采集 收起 来源:[C++]内存管理

    2016-01-12

  • 内存的申请与释放 也就是new 与delete
    查看全部
    0 采集 收起 来源:[C++]内存管理

    2016-01-12

  • 代码演示
    查看全部
  • C语言与C++ 不同
    查看全部
    0 采集 收起 来源:C++语言引用

    2016-01-12

  • 引用作函数参数
    查看全部
    0 采集 收起 来源:C++语言引用

    2016-01-12

  • 指针类型的引用
    查看全部
    0 采集 收起 来源:C++语言引用

    2016-01-12

  • #include <iostream> #include<stdio.h> using namespace std; int main(void) { int *p=new int [1000]; if(p==NULL) { system("pause"); return 0; } p[0]=10; p[1]=20; cout<<p[0]<<","<<p[1]<<endl; delete []p;//如果是delete则只删除p[0]; p=NULL; system("pause"); return 0; } /* #include <iostream> #include<stdio.h> using namespace std; int main(void) { int *p=new int (10); cout<<*p<<endl; delete p; p=NULL; system("pause"); return 0; }
    查看全部
  • #include <iostream> #include <stdio.h> using namespace std; inline void fun (double i=1.1,double j=2.2); inline void fun (int i=30,int j=20,int k=10); /*int main(void) { fun(); fun(100); fun(100,200); fun(100,200,300); system("pause"); return 0; }*/ int main(void) { fun(3.3,4.4); fun(3,4); system("pause"); return 0; } void fun (int i,int j,int k) { cout<<i<<","<<j<<","<<k<<endl; } void fun (double i,double j) { cout<<i<<","<<j<<endl; } /* 编译时将函数体代码和实参代替函数调用语句,关键字:inline,效率高,有条件; 1内联编译是建议性的,由编译器决定; 2逻辑简单,调用频繁的函数建议使用内联。 3递归函数无法使用内联方式。 函数重载是通过实参类型和个数识别的:名称相同,参数可辨。 C++函数默认值如果有,必须后几个形参都有默认值。即有默认值的参数必须全部放在最右边 函数的默认值 无实参则使用默认值,有实参则覆盖默认值 声明写默认值,定义不写默认值,编译都能通过;
    查看全部
  • /*#include <iostream> #include <stdio.h> using namespace std; void fun (const int &a,const int &b); int main(void) { int x=3; int y=5; fun(x,y); cout<<x<<endl; cout<<y<<endl; system("pause"); return 0; } void fun (const int &a,const int &b) { a=10; b=20; } >d:\documents\visual studio 2010\projects\test\test\test.cpp(18): error C3892: “a”: 不能给常量赋值 >d:\documents\visual studio 2010\projects\test\test\test.cpp(19): error C3892: “b”: 不能给常量赋值 #include <iostream> #include <stdio.h> using namespace std; int main(void) { int x=3; int y=5; int const*p=&x; cout<<*p<<endl; p=&y; cout<<*p<<endl; system("pause"); return 0; }
    查看全部
  • const int *p=null;与 int const * p=null等价 不与 int *const p=null等价; const int * connst p=null;与 int const * const p=null等价 int x=3;const int *p =$x; //p=&y;正确//*p=4;错误 int x=3;int * const p=&x;//p=&y;将是错误的; const int x=3;const int * const p=$x; //p=&y;*p=4;都是错误的 int x=3;const int &y=x; //x=10;正确// y=20;错误 const int x=3;x=5//错误 int x=3;const int y=x;y=5;//错误 int x=3;const int *y=&x;*y=5//错误 int x=3,z=4; int * oonst y=&x;y=&z;//错误 const int x=3;const int &y=x;y=5;//错误 const int x=3; int *y=&x;//错误 int x=3;const int *y=&x//正确
    查看全部
    0 采集 收起 来源:C++语言-const

    2018-03-22

  • #include <iostream> using namespace std; void fun(int &a,int &b) { int c=0; c=a; a=b; b=c; } int main(void) { int x=10,y=20; fun(x,y); cout<<x<<endl<<y<<endl; system("pause"); return 0; } /*#include <iostream> using namespace std; void fun(int *a,int *b) { int c=0; c=*a; *a=*b; *b=c; } int main(void) { int x=10,y=20; fun(&x,&y); cout<<x<<endl<<y<<endl; system("pause"); return 0; } #include <iostream> using namespace std; int main(void) { int a =10; int *p=&a; int *&q=p; *q=20; cout<<a<<endl; system("pause"); return 0; } #include <iostream> using namespace std; typedef struct { int x; int y; }Coor; int main(void) { Coor c1; Coor &c=c1; c.x =10; c.y =20; cout<<c1.x<<c1.y<<endl; system("pause"); return 0; } #include <iostream> using namespace std; int main(void) { int a =3; int &b=a;//引用必须初始化 b=10; cout<<a<<endl; system("pause"); } */
    查看全部
    0 采集 收起 来源:C++语言引用

    2018-03-22

举报

0/150
提交
取消
课程须知
本课程是C++初级课程 熟练掌握C语言开发语言基础语法
老师告诉你能学到什么?
1、C++语言引用的魅力 2、C++语言const的用法 3、C++语言函数默认值及函数重载 4、C++语言内存管理

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!