いろいろなテクニック.Nucleo と DISCO-F746 用.

Dependencies:   Array_Matrix mbed

ArrayExampleInClass.hpp

Committer:
MikamiUitOpen
Date:
2019-04-10
Revision:
1:bbb9f0c3e523

File content as of revision 1:bbb9f0c3e523:

//--------------------------------------------
//  クラス中の Array クラスのオブジェクトの初期化
//--------------------------------------------

#include "Array.hpp"
using namespace Mikami;

class IncludeArray
{
public:
    IncludeArray(int size)
        : x1_(size, -1),    // サイズと配列の内容を初期化
          x2_(size) {}      // サイズのみ初期化,この場合配列の初期状態の内容が         
                            // どうなっているかは不定

    void PrintOutX1() { PrintOut(x1_); }
    void PrintOutX2() { PrintOut(x2_); }
private:
    Array<float> x1_, x2_;
    void PrintOut(Array<float> x)
    {
        for (int n=0; n<x.Length(); n++)
            printf("    %f\r\n", x[n]);
    }
};
 
void ArrayInClass()
{
    printf("\r\nクラス中の Array クラスのオブジェクトの初期化\r\n");

    IncludeArray myArray(4);
    printf("x1:\r\n");
    myArray.PrintOutX1();
    printf("x2\r\n");
    myArray.PrintOutX2();
}