LIFE LOG(ここにはあなたのブログ名)

あつあつ備忘録

ソフトやハード、時にはメカの備忘録をまとめていきます

2019-05-29から1日間の記事一覧

【C++】コンストラクタ関数のオーバーロード

コンストラクタ関数もオーバーロードできる コンストラクタをオーバーロードするメリット 柔軟性を得る 配列のサポート コピーコンストラクタを作成すること study145.cpp #include <iostream> using namespace std; class myclass { int x; public: myclass() { x = 0</iostream>…

【C++】参照の返し

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>…