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

相关推荐
Coovally AI模型快速验证22 分钟前
MMYOLO:打破单一模式限制,多模态目标检测的革命性突破!
人工智能·算法·yolo·目标检测·机器学习·计算机视觉·目标跟踪
一只小bit25 分钟前
C++之初识模版
开发语言·c++
可为测控1 小时前
图像处理基础(4):高斯滤波器详解
人工智能·算法·计算机视觉
Milk夜雨1 小时前
头歌实训作业 算法设计与分析-贪心算法(第3关:活动安排问题)
算法·贪心算法
CodeClimb1 小时前
【华为OD-E卷 - 第k个排列 100分(python、java、c++、js、c)】
java·javascript·c++·python·华为od
BoBoo文睡不醒2 小时前
动态规划(DP)(细致讲解+例题分析)
算法·动态规划
apz_end2 小时前
埃氏算法C++实现: 快速输出质数( 素数 )
开发语言·c++·算法·埃氏算法
仟濹3 小时前
【贪心算法】洛谷P1106 - 删数问题
c语言·c++·算法·贪心算法
北顾南栀倾寒3 小时前
[Qt]系统相关-网络编程-TCP、UDP、HTTP协议
开发语言·网络·c++·qt·tcp/ip·http·udp
CM莫问3 小时前
python实战(十五)——中文手写体数字图像CNN分类
人工智能·python·深度学习·算法·cnn·图像分类·手写体识别