⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e03-03.cpp

📁 游戏开发数据结构-Data.Structures.for.Game.Programmers
💻 CPP
字号:
// =======================================================
//  Chapter 3, Example 3
//  The Array Class
// =======================================================
#include "Array.h"



void main()
{
    // create two arrays, one for an integer array
    // and one for a float array.
    Array<int> intarray( 10 );
    Array<float> floatarray( 5 );

    // use the access operator to store values.
    intarray[0] = 10;
    floatarray[0] = 3.1415f;

    // use the access operator to retrieve values.
    int i = intarray[0];
    float f = floatarray[0];
    
    // store values at index 1 in both arrays.
    intarray[1] = 12;
    floatarray[1] = 6.28f;

    // insert values between cells 0 and 1 in both arrays.
    intarray.Insert( 11, 1 );
    floatarray.Insert( 4.2f, 1 );

    // remove the items at cell 0 in both arrays.
    intarray.Remove( 0 );
    floatarray.Remove( 0 );

    // resize both arrays
    intarray.Resize( 3 );
    floatarray.Resize( 4 );

    // both arrays are automatically deleted by the Array
    // class destructor.
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -