「= 2.0」が コンストラクタのすべての引数の後に存在している理由しかし、私は理解していない..私はC++で始めていると私はクラスのこのコードC++のコンストラクタはすべての引数に "= 2.0"を付けていますか?
class Box { public: static int objectCount; // Constructor definition Box(double l=2.0, double b=2.0, double h=2.0) { cout <<"Constructor called." << endl; length = l; breadth = b; height = h; // Increase every time object is created objectCount++; } double Volume() { return length * breadth * height; } private: double length; // Length of a box double breadth; // Breadth of a box double height; // Height of a box };
を見つけました誰かが私を説明することはできますか?
C++を使い始めるのであれば、初心者のC++ブックを読むほうが効率的かもしれません。 – juanchopanza
これらはデフォルトの関数引数です。そのことについては、 –
juanchopanza - >それを検索してください。 – gigi