第一个程序,输入输出:

#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;//endl 换行
  int a;
cin>>a;
return ;
}

注释:

#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
return 0;
}

  

数据类型

类型 关键字
布尔型 bool
字符型 char
整型 int
浮点型 float
双浮点型 double
无类型 void
宽字符型 wchar_t

              要使用string类型,需要引入#include <string>

Extern 变量的使用

文件A.cpp
#include <iostream> extern int count; void write_extern(void) //(void)表示无输入参数 也可以不填写
{
std::cout << "Count is " << count << std::endl;
} 文件main.cpp
int count ;
extern void write_extern();
void main()
{
count =1;
write_extern();
}

  

定义函数

return_type function_name( parameter list )
{
body of the function
}

数据结构

struct Books
{
char title[50];
char author[50];
char subject[100];
int book_id;
}book;

类定义

class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};

类使用

	#pragma region 类的使用
Student *pStu = new Student; //在堆中 需要手动回收
pStu -> name = "小明";
pStu -> age = 15;
pStu -> score = 92.5f;
pStu -> say();
delete pStu; //删除对象 Student s; //在栈中 自动回收
s.name="1111";
s.age=23;
s.score=22;
s.say();
Student stu;
stu.name="2";
stu.age=2;
stu.score=2;
stu.say();
cout<<&s<<";"<<&stu<<endl;
#pragma endregion

引用类 类名+ 定义名(参数),无参数时直接 类名+定义名

->就是用指针调用函数或者获取数据。
a->b等价于(*a).b 函数不需要加分号
类或者结构体后面才需要分号

最新文章

  1. [No00007A]没有文件扩展&quot;.js&quot;的脚本引擎 解决办法
  2. Python下载进度条
  3. List集合基于某个字段排序
  4. Python :open文件操作,配合read()使用!
  5. [1008]harder_prime
  6. java中遇到过的String的一些特性
  7. 在ASP.NET 5中显示错误信息
  8. [BIM]STEP标准和EXPRESS语言
  9. herf窗口点击跳转
  10. HTTP长连接200万尝试及调优
  11. 聚类算法:K均值、凝聚层次聚类和DBSCAN
  12. 海量数据挖掘--DB优化篇
  13. 详解android的号码匹配
  14. VUE请求本地数据的配置json-server
  15. ffmypeg 视频处理类库使用方法
  16. 【转载】ASP.NET Core Web 支付功能接入 支付宝-电脑网页支付篇
  17. An Overview of End-to-End Exactly-Once Processing in Apache Flink (with Apache Kafka, too!)
  18. 判断点在不在多边形范围内c#
  19. 实战--Keepalived和LVS实现负载高可用
  20. java正则积累

热门文章

  1. PHP——修改数据库2-加提示框,加登录页面
  2. 22SpringMvc_jsp页面上的数据传递到控制器的说明
  3. CentOS切换桌面模式和命令行模式
  4. Thinkphp新增字段无法插入到数据库问题
  5. Android API Guides---Bluetooth
  6. ios开发之--键盘的监听
  7. iOS 开发之 -- UDID和UUID的详解
  8. Lua中 MinXmlHttpRequest如何发送post方式数据
  9. C++变量命名方案
  10. php实现简单的权限管理