#include<iostream> 直接在系统中查找头文件;
#include"iostream"现在创建的文件夹下查找头文件,没找到再在系统中查找;
main函数:主程序的入口,有且仅有一个;
字符串常量:内容永远不会发生改变;
用双引号扣起来("bit"),的是字符串;
用单引号扣起来('b'),的是字符也可是ASCII码;
常量:不可修改的值;
变量:可修改的值;
using namespace std;
std::cout << "bit" <<std::endl;
C++避免名字冲突:使用命名空间;
std是一个命名空间,cout(endl(表示”回车符“))是std命名空间内的一个”对象“;
#include<iostream>
#include<String>
namespace China{
std::string capital = "北京";
float population = 1.34;
}
namespace Japa{
std::string capital = "东京";
float population = 1.1;
}
using namespace China;//China使用命名空间,内部的成员直接使用,无需作用域
//using China::capital; 直接使用命名空间内的成员
//using China::population;
int main()
{
std::cout << "首都" << capital << std::endl;
std::cout << "人口" << population << "亿" << std::endl;
std::cout << "首都" << Japa::capital << std::endl;
std::cout << "人口" << Japa::population << "亿" << std::endl;
return 0;
}
printf("%d\n%lf\n", 12, 12.3);\n:换行;%d(占位符):整数;%lf(占位符):浮点数;
”打印“指:将信息输出到”标准输出设备“;
程序生成的4个阶段:
源程序(c.cpp)→(第一次处理)预处理(g++ -E c.cpp -o a.cpp)→源程序(a.cpp)→(第二次处理)编译(g++ -S a.cpp -o a.s)→汇编程序(a.s)→汇编(g++ -c a.s -o a.o)→二进制程序(a.o)→链接(g++ a.o -o a.exe)(这个过程中会引入C++头文件)→可执行文件(a.exe)
常见错误一:VS中文乱码的问题:强制指定文件执行
#pragma execution_character_set("gbk")
常见错误二:360的查杀问题:因为很多病毒程序基本上都是,控制台程序,所以,有时Debug时,360会拦截,可以加入白名单或阻止拦截。
常见错误三:LINK :fatal error LNKL561:必须定义入口点
原因:main函数,没写或写错。
常见英语单词:
IDE 集成开发环境;fatal error 致命错误;main 主要的;include 包含的;io 输入输出;
stream 流;iostream 输入输出流;system 系统;return 返回;void 空;int 整数数据;
Windows 窗口;pause 暂停;print 打印;cout(console output) 输出;cin 输入;
console 控制台;output 输出;input 输入;endl 行结束符(回车换行);line 行;end 结束;
debug 调试;release 发布;use 使用;using 正在使用;namespace 命名空间;
char(character)字符;int(integer)整数;short短的;long长的;unsigned无符号的;
double双倍的;float浮动,浮点数;name名字;password密码;precision精度(cout.percision(4));flags标记(cout.flags(XXX));fixed固定的(cout.flags(cout.fixed));
unset复原(cout,unsetf(cout.fixed));const常量(constant);variable变量;used使用;
without没有;initialized初始化;