2019-05-29から1日間の記事一覧
コンストラクタ関数もオーバーロードできる コンストラクタをオーバーロードするメリット 柔軟性を得る 配列のサポート コピーコンストラクタを作成すること study145.cpp #include <iostream> using namespace std; class myclass { int x; public: myclass() { x = 0</iostream>…
stdudy135.cpp #include <iostream> using namespace std; int &f(); int x; int main() { f() = 100; cout << x << "\n"; return 0; } int &f() { return x; } $ ./study135 100 f() = 100;はf()によって返される参照に100を代入している return x;はxへの参照(x</iostream>…