Re: [問題] 谷哥coding style的學習
※ 引述《rosemary0401 (rosemary)》之銘言:
: 最近再看google的coding style
: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
: 有些地方不是很懂
: <Question 3>
: Names and Order of Includes
: Use standard order for readability and to avoid hidden dependencies: C
: library, C++ library, other libraries' .h, your project's .h.
: 這樣規定的好處是什麼呢?
→
11/13 04:34,
11/13 04:34
→
11/13 04:35,
11/13 04:35
→
11/13 04:35,
11/13 04:35
→
11/13 04:36,
11/13 04:36
不是很懂為什麼錯誤的訊息會出現在別的header裡??
有人可以用sample code舉例一下,在什麼情況下,A.h的錯誤訊息會出現在B.h裡嗎??
<New Question 1>
Forward Declarations
Cons:
* It can be difficult to determine whether a forward declaration or a full
#include is needed for a given piece of code, particularly when implicit
conversion operations are involved. In extreme cases, replacing an #include
with a forward declaration can silently change the meaning of code.
若牽涉到隱式轉換的話,為什麼會難以決定到底要用#include或forward declaration呢?
而且用forward declaration來代替#include,為什麼會改變code的意思呢??
<New Question 2>
Copy Constructors
Decision:
Few classes need to be copyable. Most should have neither a copy constructor
nor an assignment operator....
這裡提到只有少數的class有copy的需求,
這就是為什麼c#和java會把class設為reference type,
而不是像C\C++一樣把class設為value type的原因嗎???
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.153.199
推
12/04 23:17, , 1F
12/04 23:17, 1F
推
12/05 01:46, , 2F
12/05 01:46, 2F
→
12/05 02:44, , 3F
12/05 02:44, 3F
→
12/05 02:45, , 4F
12/05 02:45, 4F
→
12/05 02:46, , 5F
12/05 02:46, 5F
→
12/05 02:46, , 6F
12/05 02:46, 6F
→
12/05 02:47, , 7F
12/05 02:47, 7F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章