黑马阶段三 C++篇 one day
1.c++
1.hello Word c框架详情
2.三大特性
3.命名空间 运算符特性
4.using声明
5.c与c++部分不同
1.c++是c语言前身
include
//头文件
using namespace std;
//空间 从此处开始
int main()
{
//打印代码 endl清空缓冲区
cout << "我" << endl;
return 0;
}
2.c++三大特性
封装、继承、多态
3.命名空间
1.当共同合作项目时候 避免出现变量名不同的问题
2.命名空间和镶套命名空间
3.命名空间随时可以加入新成员
4.匿名空间
5.取别名
运算符特性打印 告知变量在哪个定义域
include
//头文件
using namespace std;
//空间 从此处开始
namespace MK
{
namespace TO
{
int c = 0;
}
int a = 0;
int b = 0;
}
//匿名
namespace
{
int m = 0;
}
//取名字
namespace ZK=MK;
int main()
{
//打印代码 endl清空缓冲区
cout << MK::TO::c<< endl;
return 0;
}
4.using声明
让某个命名空间的标识符可以直接使用
//打印代码 endl清空缓冲区
cout << a << endl;//erro
using MK::a;
cout << a << endl;
5.c与c++部分不同
1.结构体
1.无需取别名 2.可以写函数
2.三目运算符
a>b?a:b
if(a>b)
{
return a;
}else
{
return b;
}
c直接返回 A的值 C++返回的是地址
3.const区别
c语言中 会分配内存 可以间接修改
C++ 打印时
cout<<a<<endl; 直接将A化为常量 发生了常量折叠
全局const 没有内存
本文来自博客园,作者:逆向狗,转载请注明原文链接:https://www.cnblogs.com/Agtw/p/17220222.html