Introduction to c++

1. keywords

The first one is to introduce the keywords

here is a picture for everyone

2.namespace

The second is namespace, to prevent conflicts between variables, functions, and classes in the global domain

Let's take an example

Compile-time error, because there was a problem with a redefinition

2.namespace

Usually, we define a namespace by our names, and it can be nested, the same project can be named the same, and eventually be merged.

its useage

  1. assign namespace names and operation qualifiers

    int main()
    {
    printf("%d", N1::a);
    return 0;
    }

  2. using the "using" keywords to reference a namespace

    using N1::b;
    int main()
    {
    printf("%d", b);
    return 0;
    }

  3. using "using namespace "keywords to reference, this is commonly used

    using namespace N1;
    int main()
    {
    printf("%d", b);
    return 0;
    }

3.cin & cout

Take a example

复制代码
#include<iostream>
using namespace std;

int main()
{
	cout << "Hello world!!!" << endl;
	return 0;
}

4.The differneces in header files

The difference between c and C++ header files, to distinguish c and C++,general c++files not .h

5.std

The usage convention of std: it can be used in daily life, but it is not recommended for work

because it would expose the entire standard library

6.Default parameters

There are two types. The first is full default parameters, and the second is semi-default parameters

there are four points to knowone of them is that semi-default must be given in order from right to left, and another is that default parameter can't appear simultaneously in the declaration and definition, the third is default values must be constants or local variables, the last one is that c language doesn't support

7.Function overloading

due to the allowance in C++ for declaring several functionally similar functions with the same domain, but requiring different parameter lists

8.Quote(引用)

Quote doesn't create a new variable, it just takes another alian, all share a sigle space.

This is an example

复制代码
#include<iostream>
using namespace std;
void TestRef()
{
	int a = 10;
	int& ra = a;
	cout << a << endl;
	cout << ra << endl;
}
int main()
{
	TestRef();
	return 0;
}

cited characteristic

  1. initializations must occur when defining.

  2. a variable can have multiple references.

  3. a quotation can quatity one thing

This is an example

复制代码
#include<iostream>
using namespace std;
void TestRef()
{
	const int a = 10;
	const int& b = a;
	cout << a;
	cout << b;
}
int main()
{
	TestRef();
	return 0;
}

9.Function(作用)

  1. do the parameters

  2. make a return value

10. Efficiency

The citation is the most efficient

相关推荐
黎阳之光7 分钟前
非视距·自愈·广覆盖|黎阳之光1.4&5.8GHz宽带自愈网无线基站,重构工业级无线通信
大数据·人工智能·算法·安全·数字孪生
llilian_1615 分钟前
铷原子频率标准 以时频基准破局,为计量校准赋能 时基铷钟
网络·功能测试·单片机·嵌入式硬件·测试工具·算法
6Hzlia19 分钟前
【Hot 100 刷题计划】 LeetCode 131. 分割回文串 | C++ 回溯算法基础切割法
c++·算法·leetcode
美式请加冰23 分钟前
子序列问题
数据结构·算法·leetcode
DeniuHe24 分钟前
线性回归与逻辑回归:同为凸函数,为何一个有解析解、一个没有?
算法·机器学习·逻辑回归
披着羊皮不是狼28 分钟前
基于CNN的图像检测算法
人工智能·算法·cnn
程序员小崔日记28 分钟前
我参加了第十七届蓝桥杯 Java B 组省赛,这套题你能撑到第几题?
java·算法·蓝桥杯大赛
山栀shanzhi42 分钟前
FFmpeg编码封装流程骨架
c++·ffmpeg
6Hzlia1 小时前
【Hot 100 刷题计划】 LeetCode 1143. 最长公共子序列 | C++ 二维DP 与 哨兵技巧
c++·算法·leetcode
Allen_LVyingbo1 小时前
《狄拉克符号法50讲》习题与解析(下)
算法·决策树·机器学习·健康医疗·量子计算