1、c++中新数据类型(bool true flase)
bool flag=0;
if(flag)
{ }
else{ }
2、初始化:
(1)复制初始化:int x=1024;
(2)直接初始化: int x(1024);
3、所有变量随用随定义
4、I/O方式
输入关键字 cin
输出关键字 cout
cout <<x<<endl;
cout<<"x+y="<<x+y<<endl; (不用占位符,不用关注数据类型)
cout<<x,y,z<<endl(错误)
cin>>x;
cin>>x>>y;
cout<<oct<<x<<endl (endl 头文件#include<iosteam>)
dec/hex/boolalpha
5、命名空间(namespace)
eg : namespace A;
{
int x=0;
void fun1();
void fun2();
}
cout <<A::x<<endl;//输出A的x变量
A::fun1( );
6,例子
#include<stdlib.h>
#include<iostream>
using namespace std;
namespace A
{
int x=0;
void fun()
{
cout<<"A"<<endl;
}
}
namespace B
{
int x=2;
void fun()
{
cout<<"B"<<endl;
}
}
int main(void)
{
cout<<A::x<<endl;
B::fun();
system("pause");
return 0;
}