討論串[問題] C++ 物件陣列要怎麼做初始化?
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者guancheng (Austin)時間16年前 (2010/04/14 19:41), 編輯資訊
0
0
0
內容預覽:
要用new的話template應該可以做的到,不過我也沒這樣用過@@. 不知道有沒有什麼缺點,下面的程式給您參考. #include <iostream>. template <int x, int y>. class test{. public:. test() :a(x), b(y) { }.
(還有371個字)

推噓1(1推 0噓 2→)留言3則,0人參與, 最新作者dustlike (灰塵)時間16年前 (2010/04/14 17:14), 編輯資訊
0
0
0
內容預覽:
像是長這樣的class:. class test{. public:. test(int x, int y) :a(x), b(y) { }. private:. int a, b;. };. 現在宣告陣列arr[3],. 我想透過現有的那個建構子來初始化arr的各個元素,要怎麼寫呢?. 我知道只宣
(還有10個字)
首頁
上一頁
1
下一頁
尾頁