: 2.the :: is a scope operator
: In the class It's just used by function which i know.
: the private variable is accessed by public function.
對阿 可是你沒注意到 那個private變數 A::m 竟然不是照這
個方式被存取到了
: 3.U can't specify any value in the undeclared object because the m's memory
: is unallocated by any object.
你的說法有問題
m 為const static type 在物件未生成前就一定要初始化它 它在物件未產生前
就存在 它的life time 就跟global variable , namespace 一樣 都是到
程式終了才結速
: 4.U don't specify the type of m.
有阿 const type阿 我不知道你的編譯器如何 不過在bcb5 sp1 上它直接
認定它為const int
--
[1;31mO [1;32mr [1;33mi [1;34mg [1;35mi [1;36mn [1;31m: [1;36m<不良牛牧場> [1;33mzoo.ee.ntu.edu.tw [1;32m(140.112.18.36) [m
[1;32mWelcome to SimFarm BBS [1;36m-- [m [1;31mFrom : [ [m211.72.86.17 [1;31m] [m
沒錯是跟生成無關 但是前提下只要是在private的變數
就得讓public的函數去存取
所以想得到static的值 還是得用public的函數去存取
只是static的值 有另外一種設定方式
以你的為例 const A::m=5; //不應該在class設定初值,otherwise=>error
//初值程式會自動設定為0
> 對阿 可是你沒注意到 那個private變數 A::m 竟然不是照這
> 個方式被存取到了
請看上面說的
> 你的說法有問題
> m 為const static type 在物件未生成前就一定要初始化它 它在物件未產生前
> 就存在 它的life time 就跟global variable , namespace 一樣 都是到
> 程式終了才結速
我修正了我的說法 請看上面 也謝謝你啦 我找到我錯誤的地方嚕
--
[m※ Origin: 雲林科技大學藍天使 <bbs.yuntech.edu.tw> [From: 140.125.32.51]