Re: 請問C++ Class中 const static object 的life …
感謝回覆 但是我這樣會有link error 耶
不過我的class 不是string 而是另一個自己定義的class, 就叫他C2吧
而且我把 static const C::C2 foo("hello");是寫在 C.cpp檔中的..
不是寫在C.h檔中的, 可是改成指標就可以編譯成功,不知道哪裡會有錯
※ 引述《tinlans ( )》之銘言:
: ※ 引述《sorryChen (陳揚和)》之銘言:
: : 標題: Re: 請問C++ Class中 const static object 的life …
: : 時間: Fri Sep 19 02:49:14 2008
: : 感謝大師的指點, memory leak就是我要問的
: : 所以其實不應該用指標 不然就得自己在main 結束前把它delete 掉
: : 是這樣吧
: : 非常感謝
: : → sorryChen:可是不用指標好像沒辦法initialization 128.125.87.33 09/19 03:41
: 我一開始看的時候就很好奇,
: 為什麼你不這樣寫?
: class C {
: static const string foo;
: };
: static const string foo("hello");
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 128.125.87.33
推
09/19 18:35, , 1F
09/19 18:35, 1F
→
09/19 18:35, , 2F
09/19 18:35, 2F
推
09/30 23:10, , 3F
09/30 23:10, 3F
→
09/30 23:10, , 4F
09/30 23:10, 4F
→
09/30 23:11, , 5F
09/30 23:11, 5F
→
09/30 23:12, , 6F
09/30 23:12, 6F
→
09/30 23:13, , 7F
09/30 23:13, 7F
討論串 (同標題文章)
完整討論串 (本文為第 4 之 4 篇):