2012-09-13 24 views

回答

2

總的來說,使用變量名稱中的術語,它將currentHtml()函數的返回值存儲到manifestcurrentItemfileContent變量中。

進行分解:

((ManifestItem*)manifest->currentItem()) 

。在你的manifest類中的方法,currentItem()將返回,以及「當前項目」。 (ManifestItem*)會將此返回的項目轉換爲ManifestItem數據類型。

其餘的是,希望,不言自明的:

->fileContent = currentHtml(); 
0
((ManifestItem*)manifest->currentItem())->fileContent = currentHtml(); 

1)調用currentHtml()

2)鑄造清單的指針ManifestItem

3)解引用#2中的指針並調用其currentItem成員函數

4)解引用#3和分配給其fileContent數據成員從#1值 - 否則使用運算符=()

0

((ManifestItem*)manifest->currentItem())->fileContent = currentHtml();在cpp中的含義是什麼?

這意味着有人正在做一件壞事。

首先,通過在標題中提出問題來解決問題。其次,演員陣容是有嫌疑的跡象。但是...

您需要知道的第一件事是C++運算符優先規則。元素選擇操作->擁有鑄造操作(type)優先級,這樣就意味着我們可以重寫此爲

((ManifestItem*)(manifest->currentItem()))->fileContent = currentHtml(); 

由部分其分解,

  1. manifest對象的currentItem()成員函數被調用,大概會返回某種類型的指針。鑑於演員,我懷疑currentItem()返回一個void*指針。
  2. C風格轉換操作符將該指針轉換爲指向ManifestItem對象的指針。
  3. 該對象的fileContent成員被設置爲調用currentHtml()的結果。