事件和线程同步

事件和线程同步 函数 //创建一个时间对象 HANDLE CreateEvent( LPSECURITY_ATTRIBUTES lpEventAttributes, // SD 安全属性 BOOL bManualReset, // reset type 0自动复位(互斥)、1手动复位(通知模式) BOOL bInitialState, // initial …

Cpp9 模板

模板 下面是一个针对int的冒泡排序 // _20180301.cpp : Defines the entry point for the console application. // #include "stdafx.h" void Sort(int* arr,int nLength) { int i,k; for (i = 0;ix > base.x …

Cpp5 在堆中创建对象和引用类型

我们可以在什么地方创建对象? 全局变量区 Person p; 栈 void Max() { Person p; } 堆 new 和 delete //在堆中创建对象: Person* p = new Person(); //释放对象占用的内存 delete p; 在堆中创建对象: new``delete 在C语言中我们使用malloc申请堆空间 使用完毕后使 …

Cpp4 类成员的访问控制

好的编程习惯 -定义和实现分开 代码会有更好的可读性 但不是必须的 在头文件中只留下声明代码 Test.h struct sclass { int x; int y; int Bigger(int x,int y); int Max(int x,int y,int z); }; Test.cpp int sclass::Bigger(int x,int y) …

Cpp3 继承

什么是继承 struct Person { int age; int sex; }; struct Teacher { int age; int sex; int level; int classId; }; struct Teacher:Person { int level; int classId; }; 总结: 1、什么是继承? 继承就是数据的复制 …

Cpp2 构造函数和析构函数

什么是构造函数 #include "stdafx.h" #include struct Sclass { int a; int b; int c; int d; Sclass()//构造函数 { printf("观察这个函数 \n"); } Sclass(int a,int b,int c,int d)//构造函数 { this->a=a; …

Cpp1 封装和this指针

封装 C语言和C++语言的区别 C++是对C的补充扩展,C原有的语法C++都支持,并在此基础上扩展了一些新的语法: 继承、封装、多态、模板等等 结构体可以作为参数传递吗 struct Student { int a; int b; int c; int d; } //分析这个函数是如何传递参数的 int Plus(student s) { return …