C++编程常用技术,基础内容

//一切的开端!
#include<iostream>
using namespace std;
int main()
{
	cout<<"Helllo World"<<endl;
	return 0;
}
// g++ helloworld.cpp
  • 函数
函数重载
函数模板:建立一个通用函数 template<typename T>
  • 数组
是相同类型数据的集合
  • 指针
指针
数组和指针
字符串和指针
函数和指针:函数指针,指向函数的指针
  • 引用
引用是一种变量类型,它用于一个变量起的别名
引用作为参数
常引用:		int a;
			a = 1;
			const int &r = a;
  • 结构体,公用体,枚举
struct 结构名{
	.......
};

union 共用体类型名{
	.....
}变量名;
//可以用来判断,大端还是小端

枚举
enum 枚举类型名 {枚举常量列表};
		enum weather {sunny,cloduy,rainly,windy};
  • 预处理
1 宏定义	
		#define 宏名 字符串
		#define 宏 (参数表列) 宏
2 文件包含	
		do...while(0) 的妙用
3 条件编译
		#ifdef 标识符
			程序段 1
		#else
			程序段 2
		#endif 
4 布局控制
	#ifdef __cplusplus
		extern "C" {
	#endif
		...
	#ifdef __cplusplus
	}
	#endif
 __cplusplus是C++的预定义宏
发布了30 篇原创文章 · 获赞 5 · 访问量 2210

猜你喜欢

转载自blog.csdn.net/weixin_44408476/article/details/105148080