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

相关推荐
naruto_lnq2 小时前
分布式系统安全通信
开发语言·c++·算法
Jasmine_llq2 小时前
《P3157 [CQOI2011] 动态逆序对》
算法·cdq 分治·动态问题静态化+双向偏序统计·树状数组(高效统计元素大小关系·排序算法(预处理偏序和时间戳)·前缀和(合并单个贡献为总逆序对·动态问题静态化
爱吃rabbit的mq3 小时前
第09章:随机森林:集成学习的威力
算法·随机森林·集成学习
(❁´◡`❁)Jimmy(❁´◡`❁)3 小时前
Exgcd 学习笔记
笔记·学习·算法
YYuCChi4 小时前
代码随想录算法训练营第三十七天 | 52.携带研究材料(卡码网)、518.零钱兑换||、377.组合总和IV、57.爬楼梯(卡码网)
算法·动态规划
CSDN_RTKLIB4 小时前
【四个场景测试】源文件编码UTF-8 BOM
c++
不能隔夜的咖喱4 小时前
牛客网刷题(2)
java·开发语言·算法
VT.馒头4 小时前
【力扣】2721. 并行执行异步函数
前端·javascript·算法·leetcode·typescript
进击的小头5 小时前
实战案例:51单片机低功耗场景下的简易滤波实现
c语言·单片机·算法·51单片机
肉包_5115 小时前
两个数据库互锁,用全局变量互锁会偶发软件卡死
开发语言·数据库·c++