posted @ 2012-12-20 22:45 Roger Luo 阅读(273) 评论(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'; 阅读全文
摘要:
服务器配置安装vsftpdsudo apt-get install vsftpd客户端配置To add an ftp account to Edit PlusFollow steps 1 to 4 aboveClick "Settings"Click "ADD"Under "Description", type in a name for the accountUnder "FTP Server", type in your servr name;Under "Username", type i 阅读全文
posted @ 2012-12-20 22:08 Roger Luo 阅读(503) 评论(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 阅读(320) 评论(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 阅读(497) 评论(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 阅读(361) 评论(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 阅读(808) 评论(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 阅读(840) 评论(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 阅读(200) 评论(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)