Re: [問題] 二維陣列、vector 函式傳遞

看板C_and_CPP (C/C++)作者 (去看二輪Liar Game!)時間14年前 (2012/03/14 18:29), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
分享一下我的想法~ 現在還不支援以 a[x][y] 存取, 但加入operator[] 實作 getValue就很容易做到了 以下是介面部分~ 實作部分應該不困難~ 有須要在來討論 class InnerElement { public: InnerElement():_innerElements(gPredefinedInnerSize) {} ~InnerElement(); // manipulators bool setValue(const void* element, int index); // accessors const void* getValue(int index) const; private: vector<const void*> _innerElements; }; class OuterElement { public: OuterElement():_outerElement(gPredefinedOuterSize) {} ~OuterElement(); // manipulators bool setValue(const void* element, int indexX, int indexY); // accesors const void* getValue(int indexX, int indexY) const; private: vector<InnerElement*> _outerElements; }; class 2DVector { public: 2DVector() {} // manipulators bool setValue(const void* element, uint indexX, uint indexY); // accessors const void* getValue(uint indexX, uint indexY) const; private: OuterElement _outerArray; }; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.128.66.129 ※ 編輯: rodion 來自: 220.128.66.129 (03/14 18:37) ※ 編輯: rodion 來自: 220.128.66.129 (03/14 18:37)
文章代碼(AID): #1FO7C501 (C_and_CPP)
文章代碼(AID): #1FO7C501 (C_and_CPP)