锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 杞細http://www.shnenglu.com/benbendy/archive/2008/05/23/50830.html 杞? http://hi.baidu.com/gwabit/blog/item/7a188726f2dc91178a82a1b6.html 灞傜駭涓錛氳娉?璇剰(C++) 1.2 [Gregory95] C++:The Core Language 1.3 [Deitel98] The Complete C++ Training Course 1.4 [Stevens2000] Standard C++ Bible 1.5 [Eckel2000] Thinking in C++ 1.6 [Lippman98] C++Primer 1.7 [Struostrup2000] The C++ Programming Language 1.7 [ANSI C++] C++瑙勬牸涔?nbsp;1998.9.1 PDF鏍煎紡 2.2 [Meyers98] Effective C++ 2.3 [Sutter99] Exceptional C++ 2.4 [Sutter2001]More Exceptional C++ 灞傜駭涓夛細搴曞眰鏈哄埗(C++ Object Model) 3.1 [Ellis90] The Annotated C++ Reference Manual 3.2 [Lippman96] Inside the C++ Object Model 灞傜駭鍥涳細璁捐瑙傚康鐨勫鐢?C++/Patterns) 4.1 [Gamma95] Design Patterns錛欵lements of Reusable Object Oriented 4.2 [Alex2001]Modern C++ Design: Generic Programming and Design 絎竴涓鐣屾槸浣跨敤STL: 絎簩涓鐣屾槸浜嗚В娉涘瀷鎶鏈殑鍐呮兜涓嶴TL鐨勫鐞? 榪欎簺灝辨槸浣犲簲璇ョ湅鐨勪功錛屽鏋滀綘鎯蟲垚涓洪珮鎵嬨?/p>
]]>
http://blog.chinaunix.net/u/4206/showart_721067.html
http://blog.csdn.net/wushihua/archive/2010/07/02/5709359.aspx
linux 涓嬶細
0. bash
1. 鐢ㄦ埛浠繪剰璁劇疆“宸ヤ綔鏃墮棿”錛?#8220;浼戞伅鏃墮棿”銆傜洰鍓嶈冭檻浣跨敤鍛戒護琛屽弬鏁?done
2. 鍔ㄦ佽幏鍙?#8220;璁懼鍙?#8221;錛屽湪涓嶅悓鐨勬満瀛愪笂鐢ㄥ彲涓嶉渶淇敼 (no so urgent)
*3. 鏃墮棿鏄劇ず
鏀硅繘錛?br>1.1 濡傛灉浼戞伅璧鋒潵浜斿垎閽燂紙榛樿浼戞伅鏃墮棿錛夋墠鍥炴潵錛屽彧鍓╀笅涓嶅鐨勫伐浣滄椂闂達紝鎵嶅仛涓浼氬効鍙堣涓柇銆?br>鏈濂芥槸鍦ㄩ攣瀹氶敭榧犱簲鍒嗛挓鍚庯紝鍦ㄧ敤鎴峰洖鏉ョ數鑴戞椂鎵嶅紑濮嬭宸ヤ綔鏃墮棿璁℃椂銆?br>鑰冭檻鏂規涓錛?br>絳夊緟鐢ㄦ埛杈撳叆鍚庢墠錛堣В闄ら紶鏍囬攣瀹氾級寮濮嬭繘鍏ヤ笅涓杞伐浣滆鏃訛紙done錛?br>杈冮珮綰х殑鏂規錛?br>浼戞伅鏃墮棿緇撴潫鍚庯紝鎹曟崏鍒伴敭鐩樻垨鑰呴紶鏍囧姩浣滄墠寮濮嬩笅涓杞伐浣滆鏃躲?br>1.2 宸ヤ綔鏃墮棿紱誨紑鐢佃剳錛岃繘鍏ヤ紤鎭椂闂磋鏃躲傝嫢涓瀹氭椂闂撮敭榧犻兘娌″弽搴斻?br>(done, 鑾峰彇閿洏榧犳爣鐨勭┖闂詫紝鑻ユ瘮浼戞伅鏃墮棿榪橀暱錛岃繘鍏ユ柊涓杞殑宸ヤ綔)
2. kill sleep鍚庯紝鍙兘閿洏姘歌繙閿佷綇銆?瑙e喅鍏抽棴璇ョ▼搴忕殑鍠勫悗宸ヤ綔銆?done , use signal)
閿佷綇榧犳爣錛屼笉閿佷綇閿洏錛屽湪閿佷綇榧犳爣鏃訛紝Ctrl-C錛岀粨鏉熺▼搴忥紝浣嗛紶鏍囨病鏈夎В閿併?br>
澶囨敞錛?br>1. 鏄惁閿佸畾閿洏寰楁槑紜紝鑰冭檻鏄惁瀵逛袱闇姹傛帹鍑轟笉鍚屾柟妗堛傛殏鑰冭檻鍙攣閿洏
some note:
1.
鎿嶄綔/dev/input/event*鏂囦歡錛屽悜瀹冨啓鍏ヤ釜input_event緇撴瀯浣撳氨鍙互妯℃嫙鎸夐敭鐨勮緭鍏?br>鍝釜event鏂囦歡鍙氳繃cat /proc/bus/input/devices 鏌ョ湅銆?br>N: Name="AT Translated Set 2 keyboard"
H: Handlers=kbd event3
N: Name="Logitech USB Optical Mouse"
H: Handlers=mouse1 event4
2.
Essentially keyboard and mouse idle time can be
gleaned (indirectly) from certain lines of the /proc/interrupts file. It
seems this file contains a counter for each device
http://software.itags.org/linux-unix/330299/
Sense mouse and keyboard inactivity final solution:
/*
This is a test example.
Ref:
http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/
gcc -o idle idle_xscr2.c -lXss
*/
#include <stdio.h>
#include <X11/extensions/scrnsaver.h>
#include <unistd.h>
int main()
{
XScreenSaverInfo *info = XScreenSaverAllocInfo();
Display *display = XOpenDisplay(0);
int i=1;
for(;i<5; i++){
sleep(3);
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
printf("%ld ms\n", info->idle);
}
return 0;
}
緙栬瘧錛?br>voide@fit:~/bash$ gcc lock.c -o lock -lXss
lock.c:24:38: error: X11/extensions/scrnsaver.h: No such file or directory
lock.c: In function ‘main’:
lock.c:41: error: ‘XScreenSaverInfo’ undeclared (first use in this function)
lock.c:41: error: (Each undeclared identifier is reported only once
lock.c:41: error: for each function it appears in.)
lock.c:41: error: ‘info’ undeclared (first use in this function)
lock.c:42: error: ‘Display’ undeclared (first use in this function)
lock.c:42: error: ‘display’ undeclared (first use in this function)
root@fit:/home/voide/bash# apt-get install libxss-dev
root@fit:/home/voide/bash# gcc lock.c -o lock -lXss
root@fit:/home/voide/bash# ./lock 1800 300 /* 1800s 300s*/
Use a short time for debug
sh: ./unlock.sh: Permission denied
root@fit:/home/voide/bash# chmod +x *.sh
]]>
On the drawback side, unlike vectors, deques
are not guaranteed to have all its elements in contiguous榪炵畫鐨?storage
locations, eliminating鎺掗櫎 thus the possibility of safe access through
pointer arithmetics.
For operations that involve frequent insertion or removals of elements at positions other than the beginning or the end, deques perform worse and have less consistent iterators and references than lists.
]]>
http://www.shnenglu.com/aqazero/archive/2006/06/08/8284.html
Precedence
Operator
Description
Example
Associativity
1
()
[]
->
.
::
++
--Grouping operator
Array access
Member access from a pointer
Member access from an object
Scoping operator
Post-increment
Post-decrement(a + b) / 4;
array[4] = 2;
ptr->age = 34;
obj.age = 34;
Class::age = 2;
for( i = 0; i < 10; i++ ) ...
for( i = 10; i > 0; i-- ) ...left to right
2
!
~
++
--
-
+
*
&
(type)
sizeofLogical negation
Bitwise complement
Pre-increment
Pre-decrement
Unary minus
Unary plus
Dereference
Address of
Cast to a given type
Return size in bytesif( !done ) ...
flags = ~flags;
for( i = 0; i < 10; ++i ) ...
for( i = 10; i > 0; --i ) ...
int i = -1;
int i = +1;
data = *ptr;
address = &obj;
int i = (int) floatNum;
int size = sizeof(floatNum);right to left
3
->*
.*Member pointer selector
Member pointer selectorptr->*var = 24;
obj.*var = 24;left to right
4
*
/
%Multiplication
Division
Modulusint i = 2 * 4;
float f = 10 / 3;
int rem = 4 % 3;left to right
5
+
-Addition
Subtractionint i = 2 + 3;
int i = 5 - 1;left to right
6
<<
>>Bitwise shift left
Bitwise shift rightint flags = 33 << 1;
int flags = 33 >> 1;left to right
7
<
<=
>
>=Comparison less-than
Comparison less-than-or-equal-to
Comparison greater-than
Comparison geater-than-or-equal-toif( i < 42 ) ...
if( i <= 42 ) ...
if( i > 42 ) ...
if( i >= 42 ) ...left to right
8
==
!=Comparison equal-to
Comparison not-equal-toif( i == 42 ) ...
if( i != 42 ) ...left to right
9
&
Bitwise AND
flags = flags & 42;
left to right
10
^
Bitwise exclusive OR
flags = flags ^ 42;
left to right
11
|
Bitwise inclusive (normal) OR
flags = flags | 42;
left to right
12
&&
Logical AND
if( conditionA && conditionB ) ...
left to right
13
||
Logical OR
if( conditionA || conditionB ) ...
left to right
14
? :
Ternary conditional (if-then-else)
int i = (a > b) ? a : b;
right to left
15
=
+=
-=
*=
/=
%=
&=
^=
|=
<<=
>>=Assignment operator
Increment and assign
Decrement and assign
Multiply and assign
Divide and assign
Modulo and assign
Bitwise AND and assign
Bitwise exclusive OR and assign
Bitwise inclusive (normal) OR and assign
Bitwise shift left and assign
Bitwise shift right and assignint a = b;
a += 3;
b -= 4;
a *= 5;
a /= 2;
a %= 3;
flags &= new_flags;
flags ^= new_flags;
flags |= new_flags;
flags <<= 2;
flags >>= 2;right to left
16
,
Sequential evaluation operator
for( i = 0, j = 0; i < 10; i++, j++ ) ...
left to right
]]>
C++/OPP/OOD緋誨垪:
1.1 [Lippman2000] Essential C++
Essential C++,by Stanley B. Lippman Addison Wesley Longman
2000,276 pages
Essential C++ 涓枃鐗?nbsp;錛屼警淇婃澃 璇戯紝282欏?nbsp;
C++:The Core Language by Gregory Satir 1995 O'Reilly
C++璇█鏍稿績錛屽紶閾辰銆璇?nbsp;錛?36欏?/p>
The Complete C++ Training Course 2/e by Harvey M.Deitel 1998
Prentice Hall
C++澶у鏁欑▼(絎簩鐗?錛岄偙浠叉綐絳夈璇戯紝816欏?/p>
Standard C++ Bible 2000 Al Stevens IDG
鏍囧噯C++瀹濆吀錛屾灄涓介椊絳?nbsp;璇戯紝766欏?/p>
Thinking in C++ 2/e Bruce Eckel 2000 1470 pages Prentice
Hall
C++ 緙栫▼鎬濇兂錛屽垬瀹楃敯絳?nbsp;璇戯紝420欏?/p>
C++ Primer,3rd Editoin,by Stanley Lippman and Josee Lajoie
Addison Wesley Longman,1998 1237 pages
C++ Primer 涓枃鐗堬紝渚繆鏉?nbsp;璇戯紝1999錛?237欏?/p>
The C++ Programming Language,Special Editoin,by Bjarne
Stroustrup
Addison Wesley Longman,2000,1017 pages
C++紼嬪簭璇█緇忓吀鏈紝鍙剁鍝?nbsp;璇戯紝鍎掓灄 1999
ANSI C++ 1996 Draft
灞傜駭浜岋細涓撳緇忛獙(C++/OOP)
2.1 [Meyers96] More Effective C++
More Effective C++,by Scott Meyers,Addison Wesley,1996,318pages
More Effective C++涓枃鐗堬紝渚繆鏉幫紝鍩圭敓 2000. 318欏?/p>
Effective C++錛孲econd Edition,by Scott Meyers,Addison Wesley
Longman,1998.256pages
Effective C++ 2/e 涓枃鐗?渚繆鏉?鍩圭敓 2000.256欏?/p>
Exceptional C++錛宐y Herb Sutter,Addison Wesley
Longman,2000.208pages
Exceptional C++涓枃鐗堬紝渚繆鏉?鍩圭敓 2000.248欏?/p>
More Exceptional C++ by Herb Sutter,Addison Wesley
Longman,2001.
The Annotated C++ Reference Manual,by Margaret A.Ellis and
Bjarne Stroustrup
Addison Wesley Longman,1990,447 pages.
Inside the C++ Object Model,by Stanley Lippman,Addison Wesley
Longman,1996,280pages
娣卞害鎺㈢儲C++鐗╀歡妯″瀷錛屼警淇婃澃 璇?nbsp;
Software,
by Erich Gamma,Richard Helm,Ralph Johnson,and John
Vlissides,Addison Wesley,1995.395pages
璁捐妯″紡,鏉庤嫳鍐涚瓑璇?鏈烘宸ヤ笟鍑虹増紺?2000.254欏?/p>
Patterns Applied
by Andrei Alexandrescu,Addison-Wesley,2001,352Paper
Genericity/STL緋誨垪:
[Josuttis99]:The C++ Standard Library 錛岮 Tutorial and
Reference,by Nicolai M.Josuttis,
Addison Wesley 1999.799pages
[Austern98]:Generic Programming and the STL -Using and
Extending the C++ Standard
Template library,by Matthew H.Austern,Addison Wesley
1998.548page
絎笁涓鐣屾槸鎵╁厖STL:
[Stepanov2001]:C++ Standard Template Library by
P.J.Plauger,Alexander A.Stepanov,
Meng Lee,David R.Musser,Prentice Hall 2001
C++鐨勫洓灞傚鐣?
1銆傜▼搴忓憳銆?
鏈夋椂琚О涓鴻摑棰嗭紝鍦–++寮鍙戝皬緇勬壆婕旀湁鐢ㄧ殑瑙掕壊錛?
浣嗘槸閬囧埌璁捐闅鵑鏃訛紝闇瑕侀珮綰х▼搴忓憳鎸囧
2銆傞珮綰х▼搴忓憳
涓庢櫘閫氱▼搴忓憳鐨勫尯鍒槸錛岃兘鐙珛鍦拌В鍐沖ぇ澶氭暟C++璁捐闅鵑銆?
瑕佽揪鍒拌繖涓灞傛闇瑕佽嚦灝戠粡榪囦笁涓鏉傜殑C++PROJECT錛屽茍縐瘡浜嗕竴浜涜璁″け璐ョ殑鏁?
璁?
緇忚繃鍔姏錛屽ぇ澶氭暟C++緙栫▼浜哄憳閮借兘杈懼埌榪欎竴楂樼駭紼嬪簭鍛樼殑澧冪晫銆?
3銆備竴涓叕鍙擱噷鐨凣URU
涔熷氨鏄父璇寸殑涓杞歡鍏徃閲岀殑鐗涗漢錛屽彲縐頒負涓涓叕鍙擱噷鐨凣URU錛?
浠栦滑鎷跨潃鐩稿綋楂樼殑钖按銆傦紝棰嗗涓涓叕鍙哥殑鎶鏈璁°?
榪欐牱鐨勪漢闇瑕佸崄騫翠互涓奜O鐨勭粡楠屽茍緇忓巻澶氫釜澶у瀷杞歡鎴愬姛鍜屽け璐ャ?
4銆傚伐涓氱晫鐨凣URU
榪欐牱浜哄湪鎵鍦ㄧ殑棰嗗煙濡傞浄璐籌紝鍑犱箮寰堝皯鏈夊叕鍙歌兘澶熼泧寰楄搗浠栦滑銆?
浠栦滑閫氬父緇忚惀鐫鑷繁鐨勫挩璇㈠叕鍙搞傝揪鍒板鐣?鐨凣URU浠紝鍑犱箮鍦ㄦ瘡澶╃殑絀洪棽鏁f鏃墮棿
閲岄兘鍦ㄦ濊冩妧鏈?
瀵瑰ぇ澶氭暟紼嬪簭鍛樻潵璇達紝鎯寵揪鍒頒粬浠殑澧冪晫錛屾槸涓嶇幇瀹炵殑銆?
-------C++ FAQ
涓変綅浣滆咃細
Cline : Internet offical Forum C++FAQ 涓繪寔浜猴紝緇欐暟鍗冨悕C++宸ョ▼甯堜笂榪囪錛?
璁$畻鏈轟笓涓氬崥澹?
Lomow: 楂樼駭鏈烘瀯璁捐甯堬紝15騫碠O寮鍙戠粡楠岋紝璁$畻鏈轟笓涓氬崥澹?
Girou: 鍥介檯C++鏍囧噯濮斿憳浼氭垚鍛橈紝鏁板涓撲笟鍗氬+
]]>
char ch[10];
//file2.c
#include <stdio.h>
extern char *ch;
int main()
{
ch[0]=1;
return 0;
}
---------------------------------------
gcc file1.c file2.c -o ap
./ap
孌甸敊璇?br>-----------------------------------------------
1錛宎rray vs pointer
file2,c ch[i]瀹為檯涓婂緱鍒扮殑鏄竴涓瓧絎︼紝浣嗙紪璇戝櫒鎶婂畠褰撴垚鏄竴涓寚閽堬紝鍥犱負姝ゆ枃浠朵腑澹版槑涓烘寚閽?br>鍏堝彇鍦板潃ch鐨勫唴瀹癸紝鍔犱笂i,褰撲綔瀛楃ch[i]鐨勫湴鍧銆傚疄闄呬笂鎵璋撶殑鍦板潃鏄痗h[0]+i;
char ch[10]; 絎﹀彿ch鍏鋒湁涓涓湴鍧錛宑h[i],鍙渶灝唅+ch鍏鋒湁鐨勫湴鍧鐩稿姞錛屽啀鍙栧叾鎸囧悜鐨勫唴瀹?br>extern char *ch; ch[i],寰楀埌鍦板潃p鐨勫唴瀹癸紝鎶婂畠鍔犱笂i錛屽啀鍙栨墍寰楀湴鍧鎸囧悜鐨勫唴瀹廣?br>鑰屼簨瀹炰笂p鎸囧悜鐨勫唴瀹規槸ch[0]//one char.鑰岄潪鍦板潃銆?br>
2.瀹氫箟vs澹版槑
瀹氫箟鍙湁涓嬈★紝涓斿垎閰嶅唴瀛橈紝涓縐嶇壒孌婄殑澹版槑銆?br>澹版槑鍙嬈★紝涓嶅垎閰嶅唴瀛樸?br>
3.緙栬瘧鍣ㄤ笉涓烘寚閽堟寚鍚戠殑瀵硅薄鍒嗛厤絀洪棿錛屽彧鏄垎閰嶆寚閽堟湰韜殑絀洪棿銆?br>闄ら潪鍦ㄥ畾涔夋椂璧嬩竴string鍒濆鍖栵紝涓斿彧鍙互鏄瓧絎︿覆甯擱噺銆傚彧璇諱笉鍙慨鏀廣?br> char *p="Hello world";
p[0]='h'; //孌甸敊璇?
]]>