Ray's playground

 
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 56 下一页

2011年3月24日

Item 18: Make interfaces easy to use correctly and hard to use incorrectly(Effective C++)

摘要: Good interfaces are easy to use correctly and hard to use incorrectly. Your should strive for these characteristics in all your interfaces. Ways to facilitate correct use include consistency in interfaces and behavioral compatibility with built-in types. Ways to prevent errors include creating new . 阅读全文

posted @ 2011-03-24 18:09 Ray Z 阅读(189) 评论(0) 推荐(0) 编辑

2011年3月23日

Item 17: Store newed objects in smart pointers in standalone statements.(Effective C++)

摘要: Store newed objects in smart pointers in standalone statements. Failure to do this can lead to subtle resource leaks when exceptions are thrown. 阅读全文

posted @ 2011-03-23 21:52 Ray Z 阅读(203) 评论(0) 推荐(0) 编辑

Item 16: Use the same form in corresponding uses of new and delete.(Effective C++)

摘要: If you use [] in a new expression, you must use [] in the corresponding delete expression. If you don't use [] in a new expression, you mustn't use [] in the corresponding delete expression. 阅读全文

posted @ 2011-03-23 21:29 Ray Z 阅读(202) 评论(0) 推荐(0) 编辑

Item 15: Provide access to raw resources in resource-managing classes.(Effective C++)

摘要: APIs often require access to raw resources, so each RAII class should offer a way to get at the resource it manages. Access may be via explicit conversion or implicit conversion. In general, explicit conversion is safer, but implicit conversion is more convenient for clients.1#include<iostream> 阅读全文

posted @ 2011-03-23 21:06 Ray Z 阅读(222) 评论(0) 推荐(0) 编辑

2011年3月22日

Web Service(Chapter 28 of Cocoa Programming for Mac OS X)

摘要: 1#import"AppController.h"2#defineAWS_ID@"1CKE6MZ6S27EFQ458402"34@implementationAppController56-(id)init7{8self=[superinit];9if(self){10//Initializationcodehere.11}1213returnself;14}1516-(IBAction)fetchBooks:(id)sender17{18[progressstartAnimation:nil];1920NSString*input=[searchFie 阅读全文

posted @ 2011-03-22 15:06 Ray Z 阅读(328) 评论(0) 推荐(0) 编辑

Project Euler Problem 24

摘要: A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:012 021 102 120 201 210 阅读全文

posted @ 2011-03-22 11:56 Ray Z 阅读(208) 评论(0) 推荐(0) 编辑

Project Euler Problem 28

摘要: Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:2122 23 242520 78 91019 6 12 1118 54 3121716 15 1413It can be verified that the sum of the numbers on the diagonals is 101.What is the sum of the numbers on the diagonals in a 1001 by 100 阅读全文

posted @ 2011-03-22 10:03 Ray Z 阅读(200) 评论(0) 推荐(0) 编辑

2011年3月21日

Project Euler Problem 25

摘要: The Fibonacci sequence is defined by the recurrence relation:Fn= Fn1+ Fn2, where F1= 1 and F2= 1.Hence the first 12 terms will be:F1= 1F2= 1F3= 2F4= 3F5= 5F6= 8F7= 13F8= 21F9= 34F10= 55F11= 89F12= 144The 12th term, F12, is the first term to contain three digits.What is the first term in the Fibonacc 阅读全文

posted @ 2011-03-21 21:45 Ray Z 阅读(239) 评论(0) 推荐(0) 编辑

2011年3月19日

C++ sizeof

摘要: 1#include<iostream>2usingnamespacestd;34#definemy_sizeof(type)(char*)(&type+1)-(char*)(&type)56unionu7{8doublea;9intb;10};1112unionu213{14chara[13];15intb;16};1718unionu319{20chara[13];21charb;22};2324structs425{26inti:8;27intj:4;28inta:3;29doubleb;30};3132intmain()33{34doublex;35strin 阅读全文

posted @ 2011-03-19 11:21 Ray Z 阅读(247) 评论(0) 推荐(0) 编辑

2011年3月14日

boost::addressof

摘要: #include<iostream>#include<boost/utility.hpp>usingnamespacestd;classObject{public:inti;Object():i(0x11223344){}intoperator&(){return0;}};intmain(){Objectobj;cout<<&obj<<endl;Object*p=boost::addressof(obj);Object*p1=std::addressof(obj);cout<<p<<endl;cout< 阅读全文

posted @ 2011-03-14 22:53 Ray Z 阅读(374) 评论(0) 推荐(0) 编辑

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 56 下一页

导航