随笔分类 -  C/C++

上一页 1 2 3 4 下一页

Uva 642 - Word Amalgamation sort qsort
摘要:Word AmalgamationIn millions of newspapers across the United States there is a word game calledJumble. The object of this game is to solve a riddle, b... 阅读全文

posted @ 2014-12-06 20:45 lakeone 阅读(447) 评论(0) 推荐(0)

Invalid operator< assertion error解析
摘要:如果编写的判断式不满足strict weak ordering,就会出现Invalid operator< assertion error错误。网页:http://support.microsoft.com/kb/949171VS(其他编译器还没试过)中,sort函数要求比较函数是strict we... 阅读全文

posted @ 2014-12-06 19:42 lakeone 阅读(242) 评论(0) 推荐(0)

qsort和sort学习与比较
摘要:阅读另一篇博文Uva 642 - Word Amalgamation sort qsort1.qsort函数:原型:void qsort(void *base, int nelem, int width, int (*fcmp)(const void *,const void *));功能:使用快速... 阅读全文

posted @ 2014-11-28 18:20 lakeone 阅读(194) 评论(0) 推荐(0)

opencv打开摄像头获取视频程序
摘要://// main.cpp// opencv3//// Created by PKU on 14-9-16.// Copyright (c) 2014年 PKU. All rights reserved.//#include using namespace cv;using namespac... 阅读全文

posted @ 2014-09-17 20:03 lakeone 阅读(844) 评论(0) 推荐(0)

c++如何理解map对象的value_type是pair类型
摘要:map 是以 pair形式插入的。map中的元素的类型value_typetypedef pair value_type;value_type 被声明为 pair 但并不是简单的 pair 因为用一个非常量的迭代器或引用不能改变关联容器的Key。#include #include int mai... 阅读全文

posted @ 2014-09-08 16:04 lakeone 阅读(3999) 评论(0) 推荐(1)

关联容器执行器指定排序规则
摘要://// main.cpp// setcmp//// Created by IDM-PKU on 14-9-6.// Copyright (c) 2014年 PKU. All rights reserved.//#include #include #include "print.hpp"us... 阅读全文

posted @ 2014-09-08 15:53 lakeone 阅读(355) 评论(0) 推荐(0)

仿函数和函数配接器
摘要://// main.cpp// function_adaptor//// Created by IDM-PKU on 14-9-3.// Copyright (c) 2014年 PKU. All rights reserved.//#include #include #include #in... 阅读全文

posted @ 2014-09-03 10:34 lakeone 阅读(378) 评论(0) 推荐(0)

C++的异常处理
摘要:一、什么是异常处理 一句话:异常处理就是处理程序中的错误。二、为什么需要异常处理,以及异常处理的基本思想 C++之父Bjarne Stroustrup在《The C++ Programming Language》中讲到:一个库的作者可以检测出发生了运行时错误,但一般不知道怎样去处理它们(因为和用户具... 阅读全文

posted @ 2014-08-31 09:29 lakeone 阅读(277) 评论(0) 推荐(0)

back_insert_iterator和insert_iterator
摘要:#include #include #include #include #include void output(const std::string & s){std::cout words(4); copy(s1,s1+4,words.begin()); for_each(words... 阅读全文

posted @ 2014-08-15 19:49 lakeone 阅读(648) 评论(0) 推荐(0)

copy函数与ostream_iterator、reverse_iterator
摘要:#include #include #include int main(){ using namespace std; int casts[10]={6,7,2,9,4,11,8,7,10,5}; vector dice(10); copy(casts,casts+10,di... 阅读全文

posted @ 2014-08-15 19:46 lakeone 阅读(308) 评论(0) 推荐(0)

const_cast
摘要:#include using std::cout;using std::endl;void change(const int * pt, int n);int main(){ int pop1=38383; const int pop2=2000; cout (pt); *p... 阅读全文

posted @ 2014-07-21 21:41 lakeone 阅读(208) 评论(0) 推荐(0)

RTTI之typeid运算符
摘要:1 #include 2 #include 3 #include 4 #include 5 6 using std::cout; 7 class Grand 8 { 9 private:10 int hold;11 public:12 Gr... 阅读全文

posted @ 2014-07-20 16:59 lakeone 阅读(347) 评论(0) 推荐(0)

RTTI之dynamic_cast运算符
摘要:#include #include #include using std::cout;class Grand{ private: int hold; public: Grand(int h=0):hold(h){} virtual void Speak() const {cout Speak(... 阅读全文

posted @ 2014-07-20 16:32 lakeone 阅读(239) 评论(0) 推荐(0)

多线程异步管理——信号
摘要:#include #include #include #include #include void *sigone_program(void *arg);void *sigtwo_program(void *arg);void report(int);int main(int argc,char *... 阅读全文

posted @ 2014-06-17 10:09 lakeone 阅读(364) 评论(0) 推荐(0)

多线程读写锁机制
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 static pthread_rwlock_t rwlock; 7 #define WORK_SIZE 1024 8 char work_area[WORK_... 阅读全文

posted @ 2014-06-16 11:24 lakeone 阅读(263) 评论(0) 推荐(0)

线程的互斥锁和条件变量通信机制
摘要:1 #include 2 #include 3 #include 4 #include 5 6 #define BUFFER_SIZE 2 7 struct prodcons 8 { 9 int buffer[BUFFER_SIZE]; 10 pthre... 阅读全文

posted @ 2014-06-16 09:08 lakeone 阅读(317) 评论(0) 推荐(0)

线程同步机制之互斥锁通信机制
摘要:#include #include #include #include void *thread_function(void *arg);pthread_mutex_t work_mutex;#define WORK_SIZE 1024char work_area[WORK_SIZE];int ti... 阅读全文

posted @ 2014-06-15 17:35 lakeone 阅读(360) 评论(0) 推荐(0)

线程共享全局变量和私有全局变量
摘要:共享全局变量实例:#include #include #include #include int key=100;void *helloworld_one(char *argc){ printf("the message is %s\n",argc); key=10; printf... 阅读全文

posted @ 2014-06-15 16:27 lakeone 阅读(3002) 评论(0) 推荐(0)

线程退出前操作
摘要:#include #include #include #include void cleanup(){ printf("cleanup\n");}void *test_cancel(void){ pthread_cleanup_push(cleanup,NULL); printf(... 阅读全文

posted @ 2014-06-15 11:47 lakeone 阅读(191) 评论(0) 推荐(0)

Linux下线程pid和tid
摘要:#include #include #include #include struct message{ int i; int j;};void *hello(struct message *str){ printf("child, the tid=%lu, pid=%d\n",pt... 阅读全文

posted @ 2014-06-15 09:29 lakeone 阅读(31735) 评论(0) 推荐(1)

上一页 1 2 3 4 下一页

导航