C++
C++言語はクラスのオブジェクトにconstをつけた場合、メンバー変数にポインタ型があるとそのポインタ自体は不変にするものの、ポインタの先が示す実体は不変にならない。 #include <iostream> using namespace std; #include <cstdlib> class Test { int* i_a; public: Test() {</cstdlib></iostream>…
C++言語はクラスのオブジェクトにconstをつけた場合、メンバー変数にポインタ型があるとそのポインタ自体は不変にするものの、ポインタの先が示す実体は不変にならない。 #include <iostream> using namespace std; #include <cstdlib> class Test { int* i_a; public: Test() {</cstdlib></iostream>…