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.
オブジェクトを 0 で初期化するとどうなるのだろうか。
例えば :
Class Vehicle { } main() { Vehicle v =0; // or Vehicle v; v=0; }
Vehicle に 1 つの数値引数を取るコンストラクタがない限り、コンパイラ エラーが発生します。
Vehicle v = 0;
と同じです
Vehicle v(0);
2 番目のケースでは、代入演算子を定義する必要があります。
一般に、質問する前に実際にコンパイルしてみることをお勧めします。