• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
demps_c
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 4 5 6 7 8 9 10 11 下一页
2013年10月3日
boost第一个进程
摘要: 1 #include 2 #include 3 using namespace std; 4 using namespace boost; 5 void hello(){ 6 cout << "hello" << endl; 7 } 8 void f1(){ 9 thread thr1(&hello); 10 thread thr2(&hello); 11 thread thr3(&hello); 12 thread thr4(&hello); 13 thr1.join(); 14 thr2.join(); 15 .. 阅读全文
posted @ 2013-10-03 16:46 demps_c 阅读(510) 评论(0) 推荐(0)
多进程
摘要: 本系统centos 中多进程的编译使用g++ thread.cpp -lboost_thread-mtC++ Boost Thread 编程指南作者:dozbC++ Boost Thread 编程指南0 前言1 创建线程2 互斥体3 条件变量4 线程局部存储5 仅运行一次的例程6 Boost线程库的未来7 参考资料:0 前言标准C++线程即将到来。CUJ预言它将衍生自Boost线程库,现在就由Bill带领我们探索一下Boost线程库。就在几年前,用多线程执行程序还是一件非比寻常的事。然而今天互联网应用服务程序普遍使用多线程来提高与多客户链接时的效率;为了达到最大的吞吐量,事务服务器在单独的线程 阅读全文
posted @ 2013-10-03 16:40 demps_c 阅读(370) 评论(0) 推荐(0)
first cppunit program
摘要: 编译g++ -o hello hello.cpp -lcppunit下面是代码1 /*Program:testcppunit.cpp -- a simple hellow example which use the cppunit tool*/ 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 class Test : public CPPUNIT_NS::TestCase 10 { 11 CPPUNIT_TEST_SUITE(Test); 12 ... 阅读全文
posted @ 2013-10-03 15:57 demps_c 阅读(185) 评论(0) 推荐(0)
类与对象问题
摘要: class x{ x(int i){}};class y{ y(){}};throw x(100); 此时是抛出一个对象的(正确)throw x ; 此时应该错误的throw y();此时是抛出一个对象;正确throw y;此时错误必须有一对双括号 阅读全文
posted @ 2013-10-03 11:42 demps_c 阅读(112) 评论(0) 推荐(0)
auto_ptr智能指针
摘要: using namespace std; 4 class a{ 5 public: 6 a(int i){} 7 }; 8 9 class b{ 10 public: 11 b(){} 12 }; 13 void f1(){ 14 auto_ptr p1(new a(1)); 15 auto_ptr p2(new b); 16 }class chy{ 44 public: 45 chy(){value ++;} 46 void print(){ 47 c... 阅读全文
posted @ 2013-10-03 10:53 demps_c 阅读(163) 评论(0) 推荐(0)
模板编程
摘要: templateclass a{ 4 public: 5 a(); 6 void printall(); 7 private: 8 int size; 9 T *value; 10 }; 11 template a::a(){ 12 size = i; 13 value = new T [size]; 14 } 15 templatevoid a::printall(){ 16 for(int j=0;j a1;//如果前面已经使用了int i= 10;则如果后面给出了参数,就... 阅读全文
posted @ 2013-10-03 10:44 demps_c 阅读(314) 评论(0) 推荐(0)
关于异常
摘要: 所有标准异常归根结底都是从exception类派生而来,此类定义在头文件exception中两个主要的派生类为logic_error(报告程序逻辑错误,通过检查代码,能够发现这类错误)和runtime_error(报告运行错误,只有在程序运行时候,这类错误才能被检查到)这两个类的定义在头文件stdexcept中,通过exception::what()函数,可以从对象中得到他所保存的消息一般不要从exception派生类,而是从logic_error或者runtime_error派生自己的类class x{ 4 public: 5 class a{}; 6 class b{... 阅读全文
posted @ 2013-10-03 09:45 demps_c 阅读(170) 评论(0) 推荐(0)
2013年10月2日
异常
摘要: 当抛出一个异常时,可以使用任意类型,(包括内置类型)但通常应当为抛出的异常创建特定的类如果在一个函数内部抛出了异常,或者被这个函数所调用的其他函数抛出了异常,这个函数将会因为抛出异常而退去如果不想因为一个throw而退出函数,可以在函数中试图解决实际产生设计问题得地方设置一个try如果后面的catch捕捉成功(不仅仅是设置了catch)则不会退出此函数只要有catch成功捕捉,系统就认为该异常已经处理了throw导致一系列的事情发生1它将创建程序所抛出的对象的一个拷贝,2然后,实际上,包含throw表达式的对象返回了这个对象,即使该函数原先并未设计为返回这种对象类型匹配一个异常并不要求异常与其 阅读全文
posted @ 2013-10-02 22:48 demps_c 阅读(133) 评论(0) 推荐(0)
setjmp
摘要: 头文件是然后一般定义一个全局jmp_buf jmp;第一次setjmp(jmp) 返回值为0第二次setjmp()返回值为longjmp(jmp,value);第二个参数的值value 阅读全文
posted @ 2013-10-02 22:22 demps_c 阅读(130) 评论(0) 推荐(0)
assert
摘要: 如果assert里面的值为真,则没有任何反应,如果不为真则a.out: test.cpp:80: int main(): Assertion `i != 999' failed.Aborted显式程序名,行数,函数,哪里失败了然后调用abort可以使用字符数组给string赋值char s[] = "quanguorenming";string str = s; 阅读全文
posted @ 2013-10-02 21:40 demps_c 阅读(172) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3