いろいろなテクニック.Nucleo と DISCO-F746 用.
Dependencies: Array_Matrix mbed
Diff: ArrayExampleInClass.hpp
- Revision:
- 1:bbb9f0c3e523
diff -r bb939e0bc6e2 -r bbb9f0c3e523 ArrayExampleInClass.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ArrayExampleInClass.hpp Wed Apr 10 06:32:33 2019 +0000 @@ -0,0 +1,36 @@ +//-------------------------------------------- +// クラス中の 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(); +}