第一章 C++语言基础


1.内联函数
  ①.inline+函数名{}
  ②.编译时,直接将内联函数插入到主函数调用点

#include <iostream.h>
inline int min(int x,int y)
{
    return (x<y?x:y);

int main()

    int m=10, n=20, t;
    t=min(m,n);
    cout<<"最小値:"<< t;    
}


2.函数重载(or重载函数)
  ①.一个函数名可以对应多个函数的实现
  ②.条件:参数类型、参数个数、参数顺序 不同 (仅返回值不同,不符合)


3.常量const
  ①.const int *p; 指向不唯一,p可以指向任意变量,不可通过p修改指向对象的值
  ②.char *const p = "abc"; 指向唯一,即abc,可通过p=?修改指向对像的值
  ③.int b;
     char int *const p = &b; 指向唯一,可通过p=?修改指向对像的值


4.引用&
  ①.其实就是取地址

int a=10;
int b=&b;

猜你喜欢

转载自blog.csdn.net/qq_40757747/article/details/81546423