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

相关推荐
芒果量化10 分钟前
量化交易 - 网格交易策略实现与原理解析
python·算法·机器学习·金融
MUTA️29 分钟前
ultalytics代码中模型接收多层输入的处理
深度学习·算法·yolo·机器学习·计算机视觉
虾球xz1 小时前
游戏引擎学习第282天:Z轴移动与摄像机运动
c++·学习·游戏引擎
.小墨迹1 小时前
Apollo学习——planning模块(3)之planning_base
linux·开发语言·c++·学习·自动驾驶
feifeigo1231 小时前
基于粒子群算法的配电网重构
算法·重构
龙湾开发2 小时前
计算机图形学编程(使用OpenGL和C++)(第2版)学习笔记 10.增强表面细节(一)过程式凹凸贴图
c++·笔记·学习·3d·图形渲染
德亦周2 小时前
如何在Mac电脑上的VScode去配置C/C++环境
c++·vscode·macos
XiaoyaoCarter2 小时前
每日一道leetcode(新学数据结构版)
数据结构·c++·算法·leetcode·职场和发展·哈希算法·前缀树
晴空闲雲2 小时前
数据结构与算法-线性表-单链表(Linked List)
数据结构·算法·链表
zm2 小时前
服务器连接多客户端
java·javascript·算法