<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ~~~ template<class T> class MyArray { private: T *p; int mCapacity; int mSize; public: MyArray(int capacity) { this->mCapacity = capacity; this->mSize = 0; //T如果是Maker,這里要調用什么構造函數,要調用無參構造 p = new T[this->mCapacity]; } //拷貝構造 MyArray(const MyArray &arr) { this->mCapacity = arr.mCapacity; this->mSize = arr.mSize; p = new T[arr.mCapacity]; for (int i = 0; i < this->mSize; ++i) { p[i] = arr.p[i]; } } //賦值函數 MyArray &operator=(const MyArray &arr) { if (this->p != NULL) { delete[] this->p; this->p = NULL; } p = new T[arr.mCapacity]; this->mSize = arr.mSize; this->mCapacity = arr.mCapacity; for (int i = 0; i < this->mSize; ++i) { p[i] = arr.p[i]; } return *this; } //重載[] T &operator[](int index) { return this->p[index]; } //尾插 void Push_Back(const T &val) { if (this->mSize == this->mCapacity) { return; } this->p[this->mSize] = val; this->mSize++; } //尾刪 void Pop_Back() { if (this->mSize == 0) { return; } this->mSize--; } int getSize() { return this->mSize; } ~MyArray() { if (this->p != NULL) { delete[] p; p = NULL; } } }; class Maker { public: string name; int age; public: Maker() {} Maker(string name, int age) { this->name = name; this->age = age; } }; void printMaker(MyArray<Maker> &arr) { for (int i = 0; i < arr.getSize(); ++i) { cout << "姓名: " << arr[i].name << " 年齡: " << arr[i].age << endl; } } void test02() { MyArray<Maker> myarr(4); Maker m1("悟空", 17); Maker m2("貝吉塔", 30); Maker m3("短笛", 200); Maker m4("小林", 19); myarr.Push_Back(m1); myarr.Push_Back(m2); myarr.Push_Back(m3); myarr.Push_Back(m4); printMaker(myarr); MyArray<int> myint(10); for (int i = 0; i < 10; i++) { myint.Push_Back(i + 1); } for (int i = 0; i < 10; i++) { cout << myint[i] <<" "; } cout << endl; } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看