C++98/C++03/C++11
若水微韧
专注于3d游戏开发,专注于C++11、STL、win32、mfc、OpenGL编程,开发属于自己3D的游戏
展开
-
long long unsigned long long 的最大值最小值在不同平台测试
long long ll_min= LLONG_MIN; long long ll_max = LLONG_MAX; unsigned long long ull_max = ULLONG_MAX;long long unsigned long long 的最大值最小值在不同平台测试#include #include using namespace std;int main()原创 2015-11-01 20:17:56 · 8133 阅读 · 0 评论 -
德罗内三角形剖分生成以及opengl显示
Delaunay 三角网的优点是结构良好, 数据结构简单, 数据冗余度小, 存储效率高, 与不规则的地面特征和谐一致,可以表示线性特征和迭加任意形状的区域边界, 易于更新,可适应各种分布密度的数据等; 它的局限性是, 算法实现比较复杂和困难, 但现在已经有了较多成熟的实现算法。 Delaunay 三角网是Voronoi图的伴生图形, 它们两个是被普遍接受和采用的分析研究区域离散数据的有力工具。它是原创 2017-12-06 22:13:25 · 1211 阅读 · 0 评论 -
const std::string转换为const wchar_t* string
由const std::string转换为const wchar_t* stringc++代码:const std::string text = "汉语";std::wstring szDst; { int len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text.c_str(), -1, NULL, 0); wchar_t原创 2017-11-24 15:13:09 · 3604 阅读 · 0 评论 -
c++11多线程编程参数传递若干问题
随着计算机处理器多核的出现,程序员编写多线程的需求越来越大。当处理互相独立的任务时,我们可以更好的使用多核的多线程的效率,可以很大的提高运行速度,但是有时候提高的速度并不是成倍的提高,因为有的操作系统访问数据的命中率可能会降低,因为当操作系统切换线程的时候,我们访问的数据会有较大的差别。因此,多线程并不一定能够成倍提高运行速度。在c++11编程中,我们使用多线程的方法非常的简单,如果我们处理的任务原创 2017-11-30 17:19:30 · 1928 阅读 · 0 评论 -
快速排序
快速排序效率较高,采用分治策略,平均时间nlogn主要使用了递归算法和子数组划分,关键之处在于子数组的划分问题上,由于在原址上进行数据的修改,不必合并子数组直接上代码:// QuickSort.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #define NUM 10int ParticalSort(int a[],原创 2017-11-28 21:31:24 · 328 阅读 · 0 评论 -
C++二进制文件读写简单操作
// WriteBinaryFile.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include int _tmain(int argc, _TCHAR* argv[]){ /* * 二进制文件写数据 * */ std::cout << "二进制文件写数据:\n"; std::ofstrea原创 2017-11-01 22:11:20 · 1191 阅读 · 2 评论 -
类对象引用计数使用模板实现(奇特的递归模板模式)
有时候我们需要跟踪一个类的对象个数,又不想为每一个类去实现引用计数,我们可以使用继承思维去实现这一目标。#include "stdafx.h"#include using namespace std; class Counted {private: static int count;public: Counted() { ++count; } Counted(cons原创 2017-04-16 11:42:40 · 548 阅读 · 0 评论 -
windows下获得一个指定文件路径下的所有文件
windows下获得一个指定文件路径下的所有文件// GetAllFiles.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include #include #include #include #ifdef WIN32#include #include #endifusing namespac原创 2017-03-12 18:05:59 · 1237 阅读 · 1 评论 -
结构体获取成员偏移值、结构体内存中字节对齐问题
// StructOffset.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #define STRUCTOFFSECT(struct,member) ((size_t)&((struct*)NULL)->member)struct MyStruct{原创 2017-02-21 15:22:47 · 612 阅读 · 0 评论 -
int i=1; main() {int i=i;}有什么错?
int i=1; main() {int i=i;}有什么错?这是一道面试题,原以为编译会不通过。但是竟然编译通过,但是结果却是一个随机数代码如下#include "stdafx.h"#include using namespace std;int i = 0;int main(int argc, char* argv[]){ cout<<i<<endl; int i = i;原创 2016-05-04 18:54:53 · 2702 阅读 · 0 评论 -
fatal error C1001: INTERNAL COMPILER ERROR VC6.0BUG
fatal error C1001: INTERNAL COMPILER ERROR VC6.0BUG这是微软VC6.0的Bug不要用using namespace std;改成using std::cout;using std::endl;就可以了如以下代码:// 运算符重载.cpp : Defines the entry point for the console a原创 2016-05-02 21:43:39 · 2282 阅读 · 1 评论 -
函数指针的应用比较排序与冒泡排序指针完成
// 利用函数指针来实现比较排序 冒泡排序// test.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include using namespace std;void max_min(int* p, int m, int* max, int* min);void原创 2016-04-29 19:48:50 · 1069 阅读 · 0 评论 -
c++返回指针的函数应用于求素数的实例
函数体内,return语句的表达式的值必须是地址值这是c++返回指针的函数关键比如求素数的例子// test.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include using namespace std;int k;int* prime原创 2016-04-29 18:11:05 · 726 阅读 · 0 评论 -
C语言中动态申请连续的二维数组
可以采用多申请一些指针,然后这一些指针分别指向后面数据区中对应的位置,如一个3*4的int类型数组,我们先申请大小为sizeof(int*) * 3 + 3 * 4 * sizeof(int)的一维数组设为arr。然后arr[0]存放指向arr + sizeof(int*) * 3这个位置的指针,arr[1]存放指向arr + sizeof(int*) * 3 + 4 * sizeof(int原创 2016-03-12 10:28:42 · 2068 阅读 · 1 评论 -
c++11新特性VS2013编译器
C++11标准发布已有一段时间了, 维基百科上有对C++11新标准的变化和C++11新特性介绍的文章. 以下是关于C++11的英文版本和中文版本维基百科的链接:http://en.wikipedia.org/wiki/C++11http://zh.wikipedia.org/wiki/C++0x 目录0 简介1 候选变更2 C++核心语言的扩原创 2015-11-01 20:39:18 · 2118 阅读 · 0 评论 -
qt翻译发布管理器--lupdate和lrelease
发布管理器提供了两个工具,lupdate和lrelease。这些工具依赖于qmake项目文件。尽管你不必使用qmake。Qt项目文件lupdate和lrelease依赖于应用程序的.proQt项目文件。在项目文件中必须有除了本地语言的之外的附加语言的TRANSLATIONS部分。一个比较有代表性的条目就像这样: TRANSLATIONS = tt2_fr.ts \ ...翻译 2019-02-20 11:36:40 · 1966 阅读 · 0 评论