C++ Code
Eighty_Nine
这个作者很懒,什么都没留下…
展开
-
map管理成员函数指针
概括:将成员函数指针名和同名的string类型的变量名进行绑定,插入到map中。 在使用时就可以通过找到string类型的变量名来使用同名的函数#include "iostream"#include "string"#include "map"using namespace std;class test{public : void fun1() { cout<<"call tes原创 2016-07-18 18:03:55 · 3451 阅读 · 4 评论 -
jsoncpp实例
目录结构:content |->main.cpp |->test | |->test.h | |->test.cpp |->json | |->json.h `->cfg.json json文件://cfg.json{ "config": { "item1":[ {原创 2016-11-03 11:08:32 · 286 阅读 · 0 评论 -
c/c++读写文件
转自:http://blog.csdn.net/kingstar158/article/details/6859379/ 转自:http://blog.csdn.net/dreamcs/article/details/9495303?locationNum=5c++实现写文件: // writing on a text file #include <fstream> using name原创 2016-10-18 17:38:58 · 274 阅读 · 0 评论 -
字节存储长度判断
#include <stdio.h>#include <iostream>using namespace std;int main () { char ch[5] = "abcd"; printf("%c,%p\n",ch[0],&ch[0]); printf("%c,%p\n",ch[1],&ch[1]); cout << "-----------" << e原创 2016-10-19 10:27:25 · 939 阅读 · 0 评论 -
全局类
#include <iostream>using namespace std;class A {public: A(num):m_num(num) {cout << 1 << " " << m_num << endl;} ~A() {cout << 2 << " " << m_num << endl;}private: int m_num;};A a(1);int原创 2016-12-01 15:48:08 · 404 阅读 · 0 评论 -
fork,waitpid实现守护进程
代码://g++ main.cpp -o main#include <unistd.h>#include <stdlib.h>#include <sys/types.h>#include <sys/wait.h>#include <iostream>#include <assert.h>using namespace std;int main () { pid_t pid,w原创 2016-12-01 18:27:46 · 528 阅读 · 0 评论 -
linux c学习笔记----消息队列(ftok,msgget,msgsnd,msgrcv,msgctl)
转自:http://lobert.iteye.com/blog/1743256ftok()#include <sys/types.h>#include <sys/ipc.h>函数原型: key_t ftok( const char * pathname , int proj_id );参数: pathname 就时你指定的文件名(该文件必须是存在而且可以访问的),id是原创 2016-12-06 15:31:36 · 4292 阅读 · 0 评论 -
将终端打印定向到log文件中
//main.cpp#include <syslog.h>#include <stdio.h>#include <unistd.h>#include <fcntl.h>#include <string>#include <assert.h>int foo(void) { int fd = 0; fd = open("1.log",O_RDWR | O_CREAT | O_原创 2017-06-01 14:46:14 · 1326 阅读 · 0 评论 -
c++版线程池和任务池示例
转自:http://www.jb51.net/article/47553.htmg++ * -lpthread -o test_threadpool./test_threadpool 200 20 10 2 20fun 1=20fun 1=40fun 1=60fun 1=80fun 1=100fun 1=120fun 1=140fun 1=160fun 1=180total t原创 2017-07-17 17:07:15 · 884 阅读 · 0 评论