Monday, June 30, 2008

Arrays Are Fixed Size

C++ Primer 4/e in 4.1. Arrays there is a beware:『Some compilers allow array assignment as a compiler extension. If you intend to run a given program on more than one compiler, it is usually a good idea to avoid using nonstandard compiler-specific features such as array assignment.』
Another a caution:『Unlike the vector type, there is no push_back or other operation to add elements to the array. Once we define an array, we cannot add elements to it.
If we must add elements to the array, then we must manage the memory ourselves. We have to ask the system for new storage to hold the larger array and copy the existing elements into that new storage. We’ll see how to do so in Section 4.3.1 (p. 134).』
Chinese Translation is said:『有些編譯器允許array賦值操作,視為一種編譯器擴充功能。如果你希望程式通過一個以上的編譯器,最好避免使用非標準的編譯器特有性質,例如這裡所說的array賦值操作。
不同於vector,array並沒有push_back()或其他用來增添元素的操作。一旦我們定義了一個array,就不能再擴展它。
如果一定要為array添加元素(空間),就必須自我管理記憶體。我們必須向系統要求新空間以存放較大的array,然後複製現有元素到新空間去。』
At first array has not push_back supported it is not very convenient.

achi's Blog

Sunday, June 29, 2008

Iterators and Iterator Types

C++ Primer 4/e 3.4. Introducing Iterators ther is a terminology:『When first encountered, the nomenclature around iterators can be confusing. In part the confusion arises because the same term, iterator, is used to refer to two things. We speak generally of the concept of an iterator, and we speak specifically of a concrete iterator type defined by a container, such as vector.
What’s important to understand is that there is a collection of types that serve as iterators. These types are related conceptually. We refer to a type as an iterator if it supports a certain set of actions. Those actions let us navigate among the elements of a container and let us access the value of those elements.
Each container class defines its own iterator type that can be used to access the elements in the container. That is, each container defines a type named iterator, and that type supports the actions of an (conceptual) iterator.』
Chinese translationis said:『第一次遭遇術語iterators時可能會感到困惑。部份原因是同一個術語iterator可用來指兩件事。可以指一般的iterator概念,也可以指某容器(例如vector)所定義的具象iterator型別。
一件必須瞭解的重要事情是,有一大群型別可作為iterators使用。這些型別在概念上彼此關聯。當一個型別支援某「特定動作集」時我們稱它為iterator;它讓我們得以尋訪容器元素並存取元素值。
每個做為容器的class都定義有自己的iterator型別,可用來存取容器元素。也就是說每個容器都定意有一個名為iterator的型別,該型別支援(概念上的)iterator所能採取的動作。』
What is concrete ?I don't understand.

achi's Blog

Thursday, June 26, 2008

Only Subscript Elements that Are Known to Exist!

C++ Primer 4/e in 3.4. Introducing Iterators there is a warning:『It is crucially important to understand that we may use the subscript operator, (the [] operator), to fetch only elements that actually exist. For example,
vector ivec; // empty vector
cout <<> ivec2(10); // vector with 10 elements
cout << ivec[10]; //error
Chinese translation is said:『我們只能以subscript運算子([])取出實際存在的元素。這一點十分重要。例如:
vector ivec; // 空的 vector
cout <<> ivec2(10); // vector 內含 10 個元素
cout << ivec[10]; // 錯誤: ivec 的元素編號是0到9
擷取不存在的元素會造成執行期錯誤。編譯器並不保證能偵測出大部分此類錯誤。這個程式的執行結果無法確定,因為「擷取不存在元素」是一種不明確的行為,其結果視編譯器而不同,但幾乎可以確定會在執行期出現某種有趣的錯誤。
這個警告亦可套用於任何使用下標的時候,例如對string或(很快會看到)對內建的array取下標。
不幸的是,企圖以下標存取不存在的元素是極常見且致命的編程錯誤。所謂緩衝區上限溢位(buffer overflow)錯誤就是以下標存取不確定元素的結果。這種臭蟲是形成PC程式及其他應用程式安全問題的最常見原因。』
This is a good warning, especially when we from VB microsoft's series to C series using array often mistake the array start from 0 or 1 .

achi's Blog

Safe, Generic Programming

C++ Primer 4/e in vector there is a key concept:『Programmers coming to C++ from C or Java might be surprised that our loop used != rather than < to test the index against the size of the vector. C programmers are probably also suprised that we call the size member in the for rather than calling it once before the loop and remembering its value.
C++ programmers tend to write loops using != in preference to Part II.
Calling size rather than remembering its value is similarly unnecessary in this case but again reflects a good habit. In C++, data structures such as vector can grow dynamically. Our loop only reads elements; it does not add them. However, a loop could easily add new elements. If the loop did add elements, then testing a saved value of size would failour loop would not account for the newly added elements. Because a loop might add elements, we tend to write our loops to test the current size on each pass rather than store a copy of what the size was when we entered the loop.
As we’ll see in Chapter 7, in C++ functions can be declared to be inline. When it can do so, the compiler will expand the code for an inline function directly rather than actually making a function call. Tiny library functions such as size are almost surely defined to be inline, so we expect that there is little run-time cost in making this call on each trip through the loop.』
Chinese translation is said:『C或Java程式員可能會對「在迴圈內使用 != 而非 < 來測試索引值和vector大小」感到驚訝。C程式員可能也會對「在for內呼叫size()而非在迴圈前呼叫一次並記住其值」感到驚訝。
C++程式員習慣上傾向使用 != 而較不喜歡使用 < 來寫迴圈。倒是沒有特別理由一定要選用某個運算子。第Ⅱ篇談到泛型編程(generic programming)後讀者就會瞭解這個習慣的緣由。
「呼叫size()而非記住其值」在這裡同樣也非必要,但再次反映一個良好的習慣。在C++,vector這一類資料結構可以動態成長。雖然此處的迴圈只讀取元素,並沒有增加元素,然而迴圈內的確輕易可以加入元素。果真如此,那麼測試前儲存size就會出錯,迴圈將因此不處理新加入的元素。由於迴圈可能加入元素,所以我們傾向每次測試當下的size,而非紀錄進入的迴圈前的size。
如同第7章即將看到,C++函式可宣告為inline。一旦如此,編譯器會把inline函式的程式碼當下展開,而非產生一個函式呼叫。小型函式如size()幾乎肯定會被定義為inline,所以可預期「每個迭代都呼叫一次」只帶來很小的執行期成本。』
Using != is very suprised to me.And I generally used to remember size unless the array or object will increase or decrease as the author said.I will not use remember size.But if size use the method of the inline and the runtime cost is very low.Then changing the habit actually may be not bad.

achi's Blog

Tuesday, June 24, 2008

allenown: Facebook for Palm

allenown: Facebook for Palm
Is this true?I want to test my palm.

achi's Blog

vectorS Grow Dynamically

C++ Primer 4/e in 3.3. Library vector Type there is a key concept:『A central property of vectors (and the other library containers) is that they are required to be implemented so that it is efficient to add elements to them at run time. Because vectors grow efficiently, it is usually best to let the vector grow by adding elements to it dynamically as the element values are known.
As we’ll see in Chapter 4, this behavior is distinctly different from that of built-in arrays in C and for that matter in most other languages. In particular, readers accustomed to using C or Java might expect that because vector elements are stored contiguously, it would be best to preallocate the vector at its expected size. In fact, the contrary is the case, for reasons we’ll explore in Chapter 9.』
and a beware :『Although we can preallocate a given number of elements in a vector, it is usually more efficient to define an empty vector and add elements to it (as we’ll learn how to do shortly).』
Chinese translation is said:『vectors(及其他程式庫容器)的一個重要特性是,它們必須能夠在執行期高效地被添加元素。由於vectors能夠高效成長,所以通常最好在元素值已知時才加入元素,讓vector自己動態成長。
一如我們將在第4章所見,這個行為和C內建的arrays以及大部分其他語言的類似東西十分不同。尤其是習慣使用C或Java的讀者,或許會認為vector的元素是連續存放,因此先把vector配置為某預期大小是最好的方法。事實上相反,第9章會探討理由。』
這個當心是這樣寫的:『雖然我們可以為vector預先配置已知個數的元素,但通常定義一個空的vector然後加入元素較有效率。我們很快就會學到如何這麼做。
Before wrote C codes I was unable to solve unknown size array.I need to change using malloc() to allocate memory.Also I thinks it is veryl trouble.And later I use PHP and there is no limits the size.So C++ has the concept of the vector template.It's very coll.I like it.

achi's Blog

string::size_type

C++ Primer 4/e in 3.2.3. Operations on strings there is a best practice :『Any variable used to store the result from the string size operation ought to be of type string::size_type. It is particularly important not to assign the return from size to an int.』
Chinese translation is said :『任何用以存放string size()返回值的變數都應該是string::size_type型別。千萬別把size()返回值賦予一個int變數,切記。』
I record in my blog then I don't forget.

achi's Blog

Monday, June 23, 2008

My Canon Powershot G9 & EOS 20D: 20D 6/23 Today's Animals

My Canon Powershot G9 & EOS 20D: 20D 6/23 Today's Animals
It's beautiful.

achi's Blog

Library string Type and String Literals

C++ Primer 4/e in 3.2. Library string Type there is a caution:『For historical reasons, and for compatibility with C, character string literals are not the same type as the standard library string type. This fact can cause confusion and is important to keep in mind when using a string literal or the string data type.』
Chinese translation is said:『由於歷史因素和C相容性,字元字串字面常數(character string literals)的型別和C++標準庫的string型別並不相同。這可能會造成困惑。在使用字串字面常數或string型別時,這是一件必須放在心上的重要事情。』
Mm,I am familiar with the usage of the C syntaxs. When I change to use C++, I truly not too understand the differences between them.

achi's Blog

Sunday, June 22, 2008

Application.DisplayAlerts = False

In general using PHP COM examples, we usually touch the using of the "application->DisplayAlerts = 0;".But it can't solve the problem of the below picture.









Because our program read the sheet,and the sheet read from another sheet or another files, The excel default auto Updating Links, under tools, select options, go to the "Edit" tab and uncheck the "Ask to update automatic links". But it is inconvenient if we can set the option in our codes.http://www.excelforum.com/showthread.php?p=1933697#post1933697 therer is a post about the properAskToUpdateLinks.I test in my PHP code.And I found it is very useful.

achi's Blog

Uninitialized Variables Cause Run-Time Problems

C++ Primer 4/e in 2.3. Variables there is a caution :『
Using an uninitialized object is a common program error, and one that is often difficult to uncover. The compiler is not required to detect a use of an uninitialized variable, although many will warn about at least some uses of uninitialized variables. However, no compiler can detect all uses of uninitialized variables.
Sometimes, we’re lucky and using an uninitialized variable results in an immediate crash at run time. Once we track down the location of the crash, it is usually pretty easy to see that the variable was not properly initialized.
Other times, the program completes but produces erroneous results. Even worse, the results can appear correct when we run our program on one machine but fail on another. Adding code to the program in an unrelated location can cause what we thought was a correct program to suddenly start to produce incorrect results.
The problem is that uninitialized variables actually do have a value. The compiler puts the variable somewhere in memory and treats whatever bit pattern was in that memory as the variable’s initial state. When interpreted as an integral value, any bit pattern is a legitimate valuealthough the value is unlikely to be one that the programmer intended. Because the value is legal, using it is unlikely to lead to a crash. What it is likely to do is lead to incorrect execution and/or incorrect calculation.』
Chinese translation is said:『使用未初始化物件是個常見的程式錯誤,也是很難發現的一種錯誤。編譯器並沒有要求偵測「未初始化變數的使用」。雖然很多編譯器會對某些未初始化變數的使用發出警告,然而沒有任何編譯器能夠偵測出所有未初始化變數的使用。
有時候我們很幸運地在使用一個未初始化變數時立刻於執行期當掉。只要追蹤崩潰點,通常很容易就可以發現變數未被適當初始化。
但很多時候程式順利執行,並產生錯誤結果。更糟的是在某一台機器上執行產生正確的結果,換到另一台卻出錯。如果急病亂投醫,在不相干位置加入程式碼,很可能造成原本正確的程式突然開始產生不正確的結果。
問題在於未初始化變數其實有一個值。編譯器首先把變數「放在」記憶體某處,然後把那塊記憶體的bit樣式(無論它是什麼)當作那個變數的初值。任何bit樣式(bit pattern)被當作整數來詮釋時都是合理的 - 雖然那不是程式員所希望得到的值。因為其值合法,所以使用他不太容易造成程式崩潰。比較可能的是導致不正確的執行和(或)不正確的計算結果。』
When using PHP I often not pay attention to initialie variables, but seldom get errors so I oftn forgot to initialize variables. Especially turn back to code using C or C++, I frequently get errors, so it is a good warning.

Friday, June 20, 2008

India Broadband

I live in Taiwan and I always use Chunghwa Telecom’s Internet service providers to surf internet.Although I think is expensive and I have no idea to choice another company’s services.And I found India Broadband the site is a forum.So you can see many posts to dicuss about ISPs with news, views and reviews of Internet service providers and plans offered.Although is not useful to me in Taiwan.But if you are in India it may be useful to you.

achi's Blog

The Real Blogger Status: Adding A Google Sitemap To Your Blog

The Real Blogger Status: Adding A Google Sitemap To Your Blog
Payperpost said my blog is not being indexed by search engines.And they give me some suggestions.But some steps need sitemap so I find the post to help me add a Google sitemap to my blog.This is helpful to me.I hope I can success to submit payperpost.

achi's Blog

mysql trigger example

I want to update my situation :
If modified content of the content field is different before and after then the trigger is activate, the syntax as blew:
DELIMITER
CREATE TRIGGER audit_content BEFORE UPDATE ON conten
FOR EACH ROW BEGINIF OLD.content <> NEW.content THEN
INSERT INTO content_audit SET content_id = OLD.id,before_value = OLD.content,after_value = NEW.content;
END IF;
END;

This is too cool.If I have this function, I can go on my work.

achi's Blog

Thursday, June 19, 2008

Temporary Objects

http://urza.wordpress.com/2008/06/08/temporary-objects/
This is talk about C++ primer 4th Edtion 7.3. The return Statement. I can link this and when I go to chapter 7.I can review this post.

achi's blog

Strong Static Typing

from Strong Static Typing
C++ Primer 4/e in 2.3. Variables there is a key concept:『
C++ is a statically typed language, which means that types are checked at compile time. The process by which types are checked is referred to as type-checking.
In most languages, the type of an object constrains the operations that the object can perform. If the type does not support a given operation, then an object of that type cannot perform that operation.
In C++, whether an operation is legal or not is checked at compile time. When we write an expression, the compiler checks that the objects used in the expression are used in ways that are defined by the type of the objects. If not, the compiler generates an error message; an executable file is not produced.
As our programs, and the types we use, get more complicated, we’ll see that static type checking helps find bugs in our programs earlier. A consequence of static checking is that the type of every entity used in our programs must be known to the compiler. Hence, we must define the type of a variable before we can use that variable in our programs.』
The Chinese translation said:『C++是個靜態型別語言,意思是型別在編譯期被檢查。型別被檢查的過程稱為型別檢驗。
在大部分語言中,物件的型別限制了該物件能夠執行的操作。如果物件的型別不支援某個操作,這個物件就不能執行那項操作。
在C++中,一個操作是否合法,將在編譯期被檢查。當我們寫下一個算式,編譯器會檢查算式裡用到的物件是否按其型別所定義的方法來使用。如果不是,編譯器會產出一個錯誤訊息,不產出可執行檔。
隨著我們的程式和使用的型別愈來愈複雜,我們會看到,靜態型別檢驗有助於早期找出程式臭蟲。靜態檢驗的一個結果是,程式用到的每一個物體的型別都必須為編譯器所知。因此我們必須在程式使用某個變數之前先定義好該變數的型別。』
I coded a long time with PHP.And I think PHP has no strong static typing.So when I return to code with C or C++, I dies very much miserably.

Break The Rulez: C++ Primer 4th Edition

Break The Rulez: C++ Primer 4th Edition
I like 4th Edition more than 3rd Edition.Because I think 4th Edition is easy reading for me.

achi's blog

Don’t Rely on Undefined Behavior

C++ Primer 4/e has again a good advice:『
Programs that use undefined behavior are in error. If they work, it is only by coincidence. Undefined behavior results from a program error that the compiler cannot detect or from an error that would be too much trouble to detect.
Unfortunately, programs that contain undefined behavior can appear to execute correctly in some circumstances and/or on one compiler. There is no guarantee that the same program, compiled under a different compiler or even a subsequent release of the current compiler, will continue to run correctly. Nor is there any guarantee that what works with one set of inputs will work with another.
Programs should not (knowingly) rely on undefined behavior. Similarly, programs usually should not rely on machine-dependent behavior, such as assuming that the size of an int is a fixed and known value. Such programs are said to be nonportable. When the program is moved to another machine, any code that relies on machine-dependent behavior may have to be found and corrected. Tracking down these sorts of problems in previously working programs is, mildly put, a profoundly unpleasant task.』
Chinese translation said:『程式如果使用「無明確定的行為」,便是犯了錯誤。如果它們可以成功執行,那只是運氣使然。「無名確定義的行為」起因於未被編譯器偵測到、或太難被偵測到的程式錯誤。
不幸的是,程式如果代有無明確定義的行為,在某些情況和(或)在某個編譯器下也許能正確執行,卻無法保證在不同編譯器下或甚至目前編譯器的新版本下繼續正確執行。並且即使在某一組輸入下能夠成功執行,也不能保證在其他輸入下能夠成功。
因此,程式不應該(故意地)倚賴「無明確定義的行為」!
同樣道理,程式通常不應該倚賴與機器相依的行為,例如「假設int的大小固定且已知」等等。這種程式被稱為不可移植(nonportable)。當這種程式被移植到其他機器,我們就必須找出並修正任何與機器相依的程式碼。在原本可運行的程式中追蹤這一類的問題,說得溫和點,是件極不愉快的工作。』
Here may be mentioned the machine's problems, but many situations in different OS it makes the nonportable problems.Last year I wrote the paper and found many source codes running at Unix.But it can't be compiled at Windows.So finally I use Java to code.Although I feel Java is some slow,it can run at many different OS.
I like to choice GTK and not choice Microsoft GUI .Because I concern the portable problem.But it is diffcult to use GTK.So I like the author said : "a profoundly unleasent task".

gentle achi

some gentle.

achi go


Sophia draw a picture for me.I like the picture.Very cool!

Thursday, June 12, 2008

Initialized and Uninitialized Variables

C++ Primer 4/e has such a concept:『Initialization is an important concept in C++ and one to which we will return throughout this book.

Initialized variables are those that are given a value when they are defined. Uninitialized variables are not given an initial value:



   int val1 = 0;     // initialized
int val2; // uninitialized

It is almost always right to give a variable an initial value, but we are not required to do so. When we are certain that the first use of a variable gives it a new value, then there is no need to invent an initial value. For example, our first nontrivial program on page 6 defined uninitialized variables into which we immediately read values.


When we define a variable, we should give it an initial value unless we are certain that the initial value will be overwritten before the variable is used for any other purpose. If we cannot guarantee that the variable will be reset before being read, we should initialize it.』


And Chinese book explains:『初始化(initialization) 在C++ 中是個重要概念,本書將一再提及。


已初始化變數是「定義時便獲得初值」的變數,未初始化變數則沒有獲得初值:



int val1 = 0; //已初始化
int val2; //未初始化
「給變數一個初值」幾乎永遠是正確的行為,但並不是非那麼做不可。如果我們很肯定第一次使用某變數時會給它一個值,那麼就沒有必要為他設想一個初值。例如我們在「p.6」第一個「有所事事」的程式中定義了未初始化變數,隨後立刻把值讀入。

定義變數時應該給予初值,除非我們確定這個初值在該變數第一次被使用前會被覆蓋掉(overwritten)。如果我們無法保證為某變數讀取數值之前該變數會被重新設值(reset),就應該將初始化。』


This concept is useful to me, however in C or other languages, even though php.

pighead

Tuesday, June 10, 2008

Make Money - A new way

Ha Ha! Recenly I register a website will be the Europes biggest advertsing media on blogs.I'm very lucky.My achi's blog can be approved.The site name is Bloggerwave.Everyone in Taiwan  can try to register the site.Hope everybody earn much money.This is an excited chance.May God bless you.

Friday, June 6, 2008

Asia Area FamilySearch Support Manager


Job Vacancy



Position   Asia Area FamilySearch Support Manager


Organization  Family History Department, Worldwide Support Division

Location   Taiwan Service Center

Post Date  June 5, 2008 

Job Description 

  • Lead a large distribution organization of individuals, processes and structures that provide support to the Area Presidency, Stake Presidencies, Bishops, Family History Centers and Directors, Ward Family History Consultants, Family History Church Service Missionaries, members and non-members involved in Family History work.

  • Provide overall management, direction and decision making for FamilySearch Support in the area.

  • Design and implement strategies to increase Family History and Temple work in the area.

  • Provide recruitment, training, deployment, direction, coordination and FamilySearch tools to local missionaries and volunteers. Coordinate the work of the Asia Call Centre.

  • Work closely with the Acquisitions Division to coordinate and allocate resources to support Family History records acquisition efforts.

  • Provide local interface for priesthood leaders with the Area Support Office and the Asia Call Centre.

  • Manage the Asia Area FamilySearch Support budget.


 

Requirements 




  • Bachelor’s degree or equivalent experience in managing remotely delivered customer service.

  • A strong business background

  • A minimum of 5 years experience managing service organization in Asia including the development and implementation of business strategies.

  • Experience delivering a high level of service and support in an international environment which has diverse language and cultural challenges.

  • Excellent interpersonal, presentation and communication skills in understanding, serving, and supporting leaders, members, and non-members within a geographical region.

  • Strong leadership skills in developing a proactive vision to support the redemption of the dead.

  • Experience in Church leadership positions.

  • Financial management and budgetary control experience

  • Team building and team management experience, including working collaboratively with organizations and individuals who do not report directly to the FamilySearch Manager.

  • Fluency in both spoken and written English and Mandarin.


 

Consideration will be given to applicants living throughout the Asia ecclesiastical area. Applications close on 29th June 2008. Qualified Church members with current temple recommend, please apply with detailed resume and a recent photo to:




  •  Service Center Manager

  •   Taiwan Service Center

  •  5, Lane 183, China Hua Street, Taipei, Taiwan 106 

  •   Facsimile: 2192-4999

  •   E-mail:     LiangCa@ldschurch.org


Application will be closed on June 29, 2008