- 博客(147)
- 资源 (2)
- 收藏
- 关注
原创 boost::serialization(2)序列化基类
在派生类中序列化一个基类假如有一个基类如下:class student_info{public: student_info() {} virtual ~student_info() {} student_info(const std::string& sn, const std::string& snm, const std::string& sg) : name_(sn),
2014-05-03 13:25:32 2151
原创 socket close shutdown 点滴
socket中关闭套接字的函数close和shutdown区别socket关闭close和shutdownsocket关闭有2个close,shutdown他们之间的区别:close-----关闭本进程的socket id,但链接还是开着的,用这个socket id的其它进程还能用这个链接,能读或写这个socket idshutdown--则
2014-04-23 10:17:13 1183
原创 boost::asio学习之[八]acceptor 点滴
acceptoracceptor(io_service);acceptot(io_service, protocol_type);acceptor(io_service, endpoint_type, reuse_address = true);acceptor(io_service, protocol_type, native_handle_type);acceptor(basic_s
2014-04-23 10:16:05 9849
原创 boost::asio学习之[七] buffer
boost::asio学习 - buffer篇boost::asio::streambuf使用read_until() 和 async_read_until()读取line-based(使用"\r\n"或者其它自定义字符序列作为delimiter)数据时需要boost::asio::streambuf来缓存读取到的数据。下面是boost文档中的read_unitl()示
2014-04-17 21:06:45 1507
原创 boost::asio学习之[六]简单聊天程序
#pragma once#include #include #include namespace ChatTest{ class chat_message { public: enum {header_length = 4, max_body_length = 1024}; public: chat_message() : body_length_(0) {} s
2014-04-16 20:43:27 1204
原创 boost::asio学习之[五]运行udp tcp服务
#pragma once#include "udp_asy_service.h"#include "asy_service.h"namespace DoubleServer{ void fuo() { try { boost::asio::io_service io; AsyService::tcp_server tcp_ser(io); UdpAsySe
2014-04-14 23:05:38 1094
原创 boost::asio学习之[四]udp client server 异步server
#pragma once#include#include#include namespace UdpSyClient{ using namespace boost::asio::ip; const int MaxSize = 1024; void udp_sy_client() { try { boost::asio::io_service io;
2014-04-13 23:33:01 5732
原创 boost::asio学习之[三 .2]异步tcp service
#pragma once#include #include #include#include namespace AsyService{ using namespace boost::asio::ip; class tcp_connection : public boost::enable_shared_from_this { public: typedef boost
2014-04-13 21:41:54 1071
原创 boost::asio学习之[三]同步service,client
#pragma once#include#include#include namespace SyService{ using namespace boost::asio::ip; const int MaxSize = 1024; void sy_service() { try { boost::asio::io_service io; tcp::ac
2014-04-13 20:13:39 1003
原创 boost::asio学习之[二]boost::asio::strand
#pragma once#include #include #include namespace Strand{ using namespace boost::asio; boost::mutex mutex; void io_run(const boost::shared_ptr& io) { mutex.lock(); std :: cout << "[" <<
2014-04-13 00:51:38 3619
原创 boost::asio学习之[一]
同步计时器#pragma once#include #include #include namespace IO{ using namespace boost::asio; void fun_01() { io_service ios; deadline_timer t(ios, boost::posix_time::seconds(10)); t.wait(
2014-04-12 22:46:27 1098
转载 const const_cast
unsigned int accumulateWeight(const std::vector& vPath, const TGraph& vGraph) { unsigned int Sum = 0; TGraph &Graph = const_cast(vGraph); //EdgeIndexMap EdgeIndex = boost::get(boost::edge_w
2014-04-01 23:52:36 1027
转载 boost库中thread多线程详解3——细说lock_guard
boost::lock_guard可以说是一种比boost::unique_lock轻量级的lock, 简单一些场景可以用它就行了。看看它的源代码也很简单:templateclass lock_guard{private: Mutex& m; explicit lock_guard(lock_guard&); lock_guard& operator=(lo
2014-03-08 09:48:47 1158
转载 boost::thread mutex
1. mutex对象类mutex类主要有两种:独占式与共享式的互斥量。▲ 独占式互斥量:mutex: 独占式的互斥量,是最简单最常用的一种互斥量类型try_mutex: 它是mutex的同义词,为了与兼容以前的版本而提供timed_mutex: 它也是独占式的互斥量,但提供超时锁定功能▲ 递归式互斥量:recursive_mutex: 递归式互斥量,可以多次锁定,相应地
2014-03-08 09:43:38 1346
原创 c++ 虚函数
今天写程序,虚函数和虚析构函数的知识模糊不清了,就自己写个测试回顾一下#pragma once#include #include #include namespace WYP{ class CBase { public: CBase() : m_BaseX(0), m_ptr(NULL) {std::cout << "CBase() is call
2013-10-31 22:57:32 673
转载 realloc
realloc 原型:extern void *realloc(void *mem_address, unsigned int newsize); 用法:#include 有些编译器需要#include 功能:改变mem_address所指内存区域的大小为newsize长度。 说明:如果重新分配成功则返回指向被分配内存的指针,否则返回空指针NULL。 当内存不再使用时,应使
2013-10-10 13:12:41 680
原创 函数指针学习(还没明白具体含义难点)
#include #include #include #include #include "test.h"using namespace std;//*********************************************************************************//FUNCTION:void print(){cout << "print is ca
2013-10-10 11:05:06 612
原创 stl之3 set 与map
#pragma once#include #include #include #include #include #include #include #include#include #include namespace myPrint{templatevoid PRINT_ELEMENT(const T &coll, char *pStr = ""){typename T::const_it
2013-09-08 16:25:06 799
原创 stl学习之2 list
#pragma once#include #include #include #include #include #include #include namespace myPrint{templatevoid PRINT_ELEMENT(const T &coll, char *pStr = ""){typename T::const_iterator pos;std::cout << pStr
2013-09-06 11:51:28 550
原创 stl学习之一
#pragma once#include #include #include #include #include #include #include namespace myCopy{typedef std::vector IntVector;void fun(){IntVector iVec1, iVec2;for (
2013-09-05 15:57:30 689
转载 窗口-视区变换
窗口-视区变换在将窗口中的图形信息送到视区去输出之前,必须进行坐标变换,即将用户坐标系的坐标值转化为设备坐标系的坐标值,即窗口-视区变换。从窗口到视口的映射世界窗口用其左、上、右和下边界描述,分别是W.l,W.t,W.r和W.b。视口在屏幕窗口坐标系中描述,使用V.l,V.t,V.r,V.b,单位是像素。窗口到视口的映射是基于一个公式生成的,这个公式在世界窗口中对每个给
2013-08-23 16:46:26 4154
转载 四元数
四元数与旋转 一.四元组基础Q(x,y,z,w),其中x,y,z用来确定旋转轴,w为旋转的角度Q=w+xi+yj+zk,i,j,k为三个虚轴的单位分量I*j=kJ*k=i;K*i=j;叉乘:c=a × b= | i j k| |a1 b1 c1| |a2 b2 c2| =(b1c2-b2c1,c1a2-
2013-08-20 17:33:02 2048
原创 ogldev 教程环境配置
1 .右键工程→"Properties"→"C/C++"下,"General"→"Additional Include Directories"填入"X:\ImageMagick-6.8.5";"X:\ImageMagick-6.8.5\Magick++\lib",2 ","Preprocessor"→"Preprocessor Definitions"增加填入";_VISUALC_;
2013-08-03 13:40:36 3224 1
转载 Magick++ 6.8.5在MFC中的使用
http://blog.csdn.net/akof1314/article/details/8924915 Magick++是ImageMagick图像库的C++封装。ImageMagick是一个集创建、编辑、合成和转换图像格式的软件套件。编译步骤:1.从http://www.imagemagick.org/download/windows/ImageMagick-windows.
2013-08-02 19:50:53 1612
转载 常用链接cg 和game
cg教程下载:http://cgpeers.comhttp://cgpersia.comhttp://bbs.ideasr.com/forum-328-1.htmlhttp://bbs.ideasr.com/forum-337-1.html (杂志&期刊)http://www.rr-sc.com/http://forum.gfxnews.orghttp://rut
2013-08-02 18:01:05 3743
转载 opegl 坐标系
今天看3D模型动画代码中,发现用四元组来进行插值和旋转,了解了使用欧拉角做旋转会有万向锁的问题存在。但这个是建立在对模型坐标系进行旋转的基础上,于是又对OGL中矩阵变化的部分再次学习了一下。发现了一篇好文章,转发学习,留供查阅。 openGL使用右手坐标从左到右,x递增从下到上,y递增从远到近,z递增--------------------------------
2013-07-29 17:24:41 827
转载 OpenGL Vertex Buffer Object (VBO)
OpenGL Vertex Buffer Object (VBO)http://www.songho.ca/opengl/gl_vbo.htmlOpenGL Vertex Buffer Object (VBO)Related Topics: Vertex Array, Display List,Pixel Buffer ObjectDownload: vbo.zip
2013-07-17 08:56:17 957
原创 ply 文件格式
Ply文件格式是Stanford大学开发的一套三维mesh模型数据格式,图形学领域内很多著名的模型数据,比如Stanford的三维扫描数据库(其中包括很多文章中会见到的Happy Buddha、Dragon、Bunny兔子),Geogia Tech的大型几何模型库,北卡(UNC)的电厂模型等,最初的模型都是基于这个格式的。PLY多边形文件格式的开发目标是建立一套针对多边形模型的,结构简单但
2013-07-16 10:44:44 1179
原创 安全指针使用的例子 (也有问题)
这是c++primer中的一个例子,但还会有问题出现#includeusing namespace std;class HasPtr;class U_Ptr{ friend class HasPtr; int *ip; size_t use; U_Ptr(int *p): ip(p), use(1) {} ~U_Ptr() { delete ip; }}
2013-07-15 11:32:05 968
原创 const笔记
#include/*-------const的作用-----------*/int& fun(int i){ return i;}const& int fun(double i){ return i;}int main(){ int i=2; /*--------------有时候我们会有意或无意的改变函数的返回值-----------*/
2013-07-15 11:23:30 653
原创 c++拷贝构造函数的禁用 与 友元函数
#include#include/* 如果想禁用复试,可以把类的拷贝构造函数的访问权限设置为私有的,但是类的友元和成员可以访问 */struct No_Name{No_Name(): pstring(new std::string), i(0), d(0) {}No_Name(const std::string &str, int ii, double dd){pstring = new std:
2013-07-10 17:31:03 1665
原创 std::unique与结构体
#include#include#includestruct Pair{ int Key; float Value; bool operator bool operator==(const Pair& vp) { return (*this).Key==vp.Key;}};int main(int, char**){ std::vector ve
2013-07-06 15:59:13 2994
转载 const 思考
1、什么是const 常类型是指使用类型修饰符const说明的类型,常类型的变量或对象的值是不能被更新的。(当然,我们可以偷梁换柱进行更新:)2、为什么引入const? const 推出的初始目的,正是为了取代预编译指令,消除它的缺点,同时继承它的优点。3、cons有什么主要的作用? (1)可以定义const常量,具有不可变性。 例如
2013-07-06 14:22:15 637
原创 opengl错误解决方法 unresolved unresolved external symbol ___glutInitWithExit@12
初学opengl遇到下面错误::error LNK2001: unresolved external symbol ___glutInitWithExit@12: error LNK2001: unresolved external symbol ___glutCreateWindowWithExit@8在网上搜了N久,试了好多方法,都不行,问一高手,终解决:原因:glut.h的文
2013-07-04 09:39:05 1821 1
原创 继承与派生——虚继承
虚基类的概念 一般,不希望在一个派生类中存在某个公共基类的多个同名的成员变量。虽然也可以通过在成员变量名前面加上“类名::”消除其二义性,但解决这个问题的最好办法是使用虚基类。虚基类方法可以保证在任何一个存在公共基类的派生类中,不会存在一个以上的同名成员变量。 所谓虚基类,就是说一个类层次中,如果某个派生类存在一个公共基类,将这个基类设置为虚基类,这时从不同的路径继
2013-07-03 09:37:12 1313
原创 c++未解之谜
#include#includeusing namespace std;char * reverse_str(char* str){ if(str==NULL) return str; char *bstr=str; char *estr=str; char ch; while(*estr!='\0')estr++; estr--; while(bstr
2013-07-02 20:14:08 849
转载 全局变量,继承,虚函数,构造函数和析构函数的调用过程
/*全局变量,继承,虚函数,构造函数和析构函数的调用过程。。。///百度里发现的一个好贴,不敢独自享用,分享一下。。。*/#include class Value{ public: Value(int nVal) { m_nVal = nVal; printf("Call Value::Value(int nValue)\n"); } ~Value(
2013-07-01 15:39:32 1342
原创 静态对象的析构
#include#includeclass staticClass{public: staticClass() { printf("Initialize!\n"); // std::cout } ~staticClass() { printf("Clear up!\n"); // std::cout }};stati
2013-07-01 15:35:12 1754
原创 stl lower_bound 和 upper_bound
函数lower_bound()在first和last中的前闭后开区间进行二分查找,返回大于或等于val的第一个元素位置。如果所有元素都小于val,则返回last的位置举例如下:一个数组number序列为:4,10,11,30,69,70,96,100.设要插入数字3,9,111.pos为要插入的位置的下标则pos = lower_bound( number, number + 8,
2013-06-29 14:43:39 807
assimp--3.0.1270-source-only.zip
2013-08-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人