Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  C/C++

摘要:WinMain与mainWinMain的原型:int CALLBACK WinMain( __in HINSTANCE hInstance, __in HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nCmdShow ); WinMain的定义:WinMain is the conventional name used for the application entry point for agraphical Windows-based application.#include <Windows.h> i... 阅读全文

posted @ 2013-01-03 14:20 Roger Luo 阅读(595) 评论(0) 推荐(0)

摘要:编译错误error C2712: Cannot use __try in functions that require object unwinding附录:SEH异常代码define in <winbase.h>#define WAIT_IO_COMPLETION STATUS_USER_APC #define STILL_ACTIVE STATUS_PENDING #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION #defin... 阅读全文

posted @ 2012-12-27 09:44 Roger Luo 阅读(1379) 评论(0) 推荐(0)

摘要:C#异步调用(Asynchronou Delegate)C#异步调用获取结果方法:主要有三种,也可以说是四种(官方说四种,电子书说三种),官方在MSDN上已经有详细的说明: 链接需要了解到获取异步执行的返回值,意味着你需要调用Delegate的BeginInvoke方法,而不是Invoke方法。第一种就是书上没有说的,但是官方还是给出来的,就是通过调用EndInvoke方法来获取内容,查看如下代码: class MyState { public int ThreadId = 0; public int Data = 0; publ... 阅读全文

posted @ 2012-12-26 20:44 Roger Luo 阅读(2527) 评论(0) 推荐(0)

摘要:环境变量设置/etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行。并从/etc/profile.d目录的配置文件中搜集shell的设置。/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取。~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登 阅读全文

posted @ 2012-12-23 00:03 Roger Luo 阅读(3811) 评论(0) 推荐(0)

摘要:安装MySQL以及开发库sudo apt-get install mysql-server mysql-client libmysqlclient-dev libmysqlclient18 libmysql++-dev libmysql++3 libmysql++-docMySQL重要命令登录mysql后台mysql -uroot -p导入数据库mysql -uroot -p < northwind.sql产生一个新的用户给一个数据库grant all on Northwind.* to roger@localhost identified by 'intel@123'; 阅读全文

posted @ 2012-12-20 22:45 Roger Luo 阅读(275) 评论(0) 推荐(0)

摘要:Windows平台下的内存泄露使用CRTDBG#ifdef _DEBUG #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) #else #define DEBUG_CLIENTBLOCK #endif #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> #ifdef _DEBUG #define new DEBUG_CLIENTBLOCK int main() { char * p = new char[10]; _CrtMemDumpAllObjectsSin 阅读全文

posted @ 2012-12-18 21:57 Roger Luo 阅读(325) 评论(0) 推荐(0)

摘要:std::inistializer_list使用inistializer_list能够初始化同一类型或者能够隐式转换成统一类型的函数形参,简化函数接口的实行,例如:double Sum(std::initializer_list<double>li) { double sum = 0.0; for(auto p = li.begin(); p != li.end(); p++) { sum += *p; } return sum; }这样调用函数的方式可以是多个参数: cout<<Sum({1.2})<<endl; cout<<Sum(... 阅读全文

posted @ 2012-12-18 14:36 Roger Luo 阅读(500) 评论(0) 推荐(0)

摘要:构造函数中调用虚函数将会因为派生类没有完成自身的初始化,而使得只能调用基类的虚函数定义,如果基类没有给出虚函数的实现,则会编译出错时出错(LNK2019没有找到对应函数的实现)。析构函数中调用虚函数(同时需要保证基类析构函数是虚函数,否则删除基类指针将不会调用派生类得析构函数)。测试代码:class Base { public: Base() { cout<<"Base::Base"<<endl; Fun(); } virtual ~Base() { cout<<"Base::~Base"<<endl; F 阅读全文

posted @ 2012-12-06 11:51 Roger Luo 阅读(363) 评论(0) 推荐(0)

摘要:多线程编程使用createthread需要提供LPTHREAD_START_ROUTINE线程函数,线程函数的签名为 void (*) (void * lpParam)对于类静态函数或者全局函数,需要在LPTHREAD_START_ROUTINE强制定义ThreadProc类静态函数:需要(LPTHREAD_START_ROUTINE)Class::StaticFunction全局函数:需要(LPTHREAD_START_ROUTINE)GlobalFunctioncreatethread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, pParam, 阅读全文

posted @ 2012-11-23 17:42 Roger Luo 阅读(810) 评论(0) 推荐(0)

摘要:Copy and Swap idiom使用到著名的Big three中兩個特殊的成員函數(拷貝構造函數copy construction與賦值構造函數assignment constrcution). 作用在于在深拷贝的过程中保证强异常的作用,具体代码如下class Person { public: Person(int id, const char * pszName):_id(id), _pszName(new char[strlen(pszName) + 1]){strcpy(_pszName, pszName);} Person():_id(0) { _pszName = n... 阅读全文

posted @ 2012-11-20 19:58 Roger Luo 阅读(856) 评论(0) 推荐(0)

摘要:啊 阅读全文

posted @ 2012-11-20 15:58 Roger Luo 阅读(178) 评论(0) 推荐(0)

摘要:饭是一口一口吃的...预编译 PrecompilerCompiling C++ code is a long, slow process, especially compiling window API or other API library(boost).The Microsoft compiler can ameliorate this problem with a simple trick calledprecompiled headers. The trick is pretty slick: although every CPP file can potentially and l 阅读全文

posted @ 2012-11-17 14:07 Roger Luo 阅读(203) 评论(0) 推荐(0)

摘要:Mac XCode program1. Add additional header/librariesFor XCode project, add the "Header Search Paths" or "Library Search Paths" under "Search Paths" in xcodeproj.2. Add additional link flagsFor XCode project, for example, add "-lboost_system-xgcc42-1_51" and &qu 阅读全文

posted @ 2012-11-15 21:28 Roger Luo 阅读(250) 评论(0) 推荐(0)

摘要:Install BOOST 1. Build from source code Download the new release package from boost official website For windows, download zip or 7z format and unpack it using 7zip or winrar For linux/mac os, dow... 阅读全文

posted @ 2012-11-15 08:55 Roger Luo 阅读(390) 评论(0) 推荐(0)

摘要:traverse elements in contianer associated container: set Compare between sets if you want to find the different elements in one set to another set, you could use the std::set_difference met... 阅读全文

posted @ 2012-11-07 15:56 Roger Luo 阅读(279) 评论(0) 推荐(0)