Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
「A」という名前のクラスがあるプログラムに出くわしました。
私が理解できない変数の宣言に次の構文があります。
A& obj;
これは何を意味し、どのような場合に使用されますか。
objオブジェクトへreferenceのです。A参照はデフォルトで初期化できないため、おそらくこれはクラス データ メンバーです (最初から何かを参照する必要があります)。
obj
reference
A
struct Foo { int& a; Foo(int n) : a(n) {} // must be initialized in constructor initialization list. }