※ 引述《gyspy.bbs@bbs.cs.nctu.edu.tw (new born)》之銘言:
> 恩 不太懂耶 要是我寫的話我只會考慮array, array[0], &array[0][0]
> 這三者其一的寫法 ^^" 我程度太低了吧挖哈哈
這個要用 C++ compiler 去編譯才看得出來,
在 C 會幫你轉是沒錯,
拿以下的 code 為例:
1 int main()
2 {
3 int a[2][3];
4 int (*ptr) [3];
5
6 ptr = a[0];
7 ptr = &a[0];
8
9 return 0;
10 }
C compiler 編譯後的結果:
test.c:6: warning: assignment from incompatible pointer type
C++ compiler 編譯後的結果:
test.cxx:6: error: cannot convert `int[3]' to `int (*)[3]' in assignment
我想這樣你大概能理解我想表達的意思了。
--
Name: Tseng, Ling-hua E-mail Address: uranus@it.muds.net
School: National Tsing Hua University Department: Computer Science
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Undecided
Homepage: https://it.muds.net/~uranus
--
╔═══╗ ┼────────────────────────╮
║狂狷 ║ │* Origin:[ 狂 狷 年 少 ] whshs.cs.nccu.edu.tw ╰─╮
║ 年少║ ┼╮ < IP:140.119.164.252 > ╰─╮
╚╦═╦╝ ╰ * From:61-230-217-167.dynamic.hinet.net
─╨─╨─ KGBBS ─ ◎ 遨翔"BBS"的狂狷不馴;屬於年少的輕狂色彩 ◎