摘要:txt文件形如: 转换后的xaml文件: 转换代码如下: #include <vector> BOOL IsFileExist(LPCTSTR lpFileName) { BOOL bExist = TRUE; if(NULL == lpFileName) { return FALSE; } els
阅读全文
摘要:静态类成员: 1.静态数据成员只有一份,某个对象改变了静态变量,则其他对象的静态变量页随之改变 2.静态数据成员可以是当前类的类型 class Book { static CBook m_VCbook; CBook *m_pBook; } 3.静态数据成员可以作为函数的默认参数 4.类的静态成员函数
阅读全文
摘要:重载函数调用运算符: 如果类重载了函数调用运算符,则可以像使用函数一样操作类对象。因为这样的类同时也可以存储状态,所以比普通函数更加灵活 示例如下: #include "stdafx.h" #include "iostream" using namespace std; struct NullTyp
阅读全文
摘要:用法: 在头文件或者源文件全局中添加互斥量句柄:HANDLE m_hMutex; 在构造函数或全局创建互斥量:m_hMutex = CreateMutex(NULL,FALSE,"MutexTest"); 最后在需要保护代码的前面加上:WaitForSingleObject(m_hMutex, IN
阅读全文
摘要:话不多说,直接上马 TextQuery.h #pragma once #include <iostream> #include <vector> #include <string> #include <map> #include <set> #include <fstream> #include <
阅读全文
摘要:解释: 1.116444736000000000 // 从1601年1月1日0:0:0:000到1970年1月1日0:0:0:000的时间(单位100ns) 2. ui.QuadPart - 116444736000000000 // 从1970年1月1日0:0:0:000到现在的100ns(UTC
阅读全文
摘要:利用sort函数排序(需包含头文件#include <algorithm>) bool sortFunc( const Test &v1, const Test &v2)//本函数的参数的类型一定要与vector中一致{ return v1.member1 < v2.member1;//升序排列 }
阅读全文
摘要:有时,有两个或多个类,其功能是相同的,仅仅是数据类型不同,如下面语句声明了一个类: 单个类模板语法 #include "iostream"using namespace std; template<typename T>class A {public: A(T t) { this->t = t; }
阅读全文
摘要:c++提供了函数模板(function template.)所谓函数模板,实际上是建立一个通用函数,其函数类型和形参类型不具体制定,用一个虚拟的类型来代表。这个通用函数就成为函数模板。凡是函数体相同的函数都可以用这个模板代替,不必定义多个函数,只需在模板中定义一次即可。在调用函数时系统会根据实参的类
阅读全文
摘要:实现功能: 在指定文件中查找输入字符串所在的行 TextQuery.h TextQuery.cpp main.cpp
阅读全文
摘要:#include <iostream> int main() { std::cout << "hello, \x4DO\115" << '\n'; //hello, MOM //普通转义字符直接使用 ‘\n’ std::cout << "hello, \x4DO\115" << std::endl; //hello, MOM //泛化转义字符 \x4D(16进制表示) \115(8进制表示) st
阅读全文
摘要:#include <iostream> int main() { unsigned u = 10; int i = -42; std::cout << i + i << std::endl; //输出结果为-84 std::cout << i + u << std::endl; // i 转换为无符号整形为 2^32 + [(-42)*(-1)/2^32]*2^32 + (-42) = 42949
阅读全文
摘要:-1在内存中以补码的形式存在, 源码:1(符号位)0000 0001 补码=源码取反加1(记住:符号位不变) 即1111 1110+1 即为 1111 1111 unsigned char(1111 1111)当然就是255了 同理可推出unsigned char(-2) 为 254 顺便说一下:
阅读全文