C++之起航篇
来源:互联网 发布:telnet端口不通原因 编辑:程序博客网 时间:2024/05/20 05:58
1.应用领域
嵌入式游戏网络系统
2.诞生地
贝尔实验
3.特点
速度快内存省
4.C++和C的关系
C语言是C++的子集C++是在C面向过程的基础上增添了面向对象
5.常用IDE
VSCB
6.新的数据类型
比较与C语言,新增了bool,逻辑类型
7.新的初始化方法
C:赋值初始化,int x = 1024;C++:赋值初始化,int x = 1024; 直接初始化:int x(1024);
8.输入输出方式
C:scanf/printfC++:cin/cout好处:不用关注占位符 不用关注数据类型 不易出现问题Demo: #include <iostream> using namespace std; int main() { cout << "请输入一个整数:" << endl; int x = 0; cin >> x; cout << oct << x << endl; cout << dec << x << endl; cout << hex << x << endl; cout << "请输入一个布尔值(0、1):" << endl; bool y = false; cin >> y; cout << boolalpha << y << endl; return 0; }
9.命名空间
就是划片取名字,避免命名冲突Demo: #include <iostream> using namespace std; namespace A { int x = 1; void fun() { cout << "A" << std::endl; } } namespace B { int x = 2; void fun() { cout << "B" << endl; } void fun2() { cout << "2B" << endl; } } using namespace B; int main() { cout << A::x << endl; A::fun(); fun2(); }
10.以上的综合小Demo
#include <iostream>using namespace std;namespace compA { int getMaxOrMin(int* arr, int count, bool isMax) { int temp = arr[0]; for (int i = 1; i < count; i++) { if (isMax) { if (temp < arr[i]) { temp = arr[i]; } } else { if (temp > arr[i]) { temp = arr[i]; } } } return temp; }}
1 0
- UML之起航篇
- C++之起航篇
- 编码之旅——起航篇
- Spring.NET框架起航之认识篇
- Java之旅——起航篇
- 1.C++远航之起航篇
- C++之起航篇学习笔记
- C++远征之起航篇知识点
- 菜鸟读文献之起航篇
- imooc 学习总结:C++之起航篇
- 起航篇
- C之路,从前天正式起航了
- JSP之路起航
- SAP之旅 -- 起航
- 梦之起航
- IT之路,起航
- ACM之旅起航
- 我的嵌入式学习之旅——起航篇
- 《手机控》开发过程记录
- url传参js解析
- 线程和进程区别
- 十、Android的消息机制
- STM32——系统滴答定时器
- C++之起航篇
- 第一行代码_回顾Activity的生命周期
- .net 插件式开发学习总结
- 3D逃亡-简单搜素练习2
- this引用 和super关键字的用法
- argc与argv
- 网易校招笔试题 炮台攻击
- 练习——旋转链表问题
- java第六节-this关键字,java的内部类