Complete the code to declare a parameterized constructor for class Car.
class Car { public: int year; Car([1]) { year = y; } };
The parameterized constructor takes an integer parameter y to initialize the year attribute.
Complete the constructor initialization list to set the member variable.
class Book { int pages; public: Book(int p) : [1] {} };
The constructor initialization list uses pages(p) to initialize the member variable pages with the parameter p.
Fix the error in the parameterized constructor declaration.
class Student { int id; public: Student([1]) { id = i; } };
The constructor parameter must specify the type followed by the variable name, like int i.
Fill both blanks to complete the constructor that initializes two member variables.
class Point { int x, y; public: Point(int a, int b) : [1], [2] {} };
The constructor uses the initialization list to set x with a and y with b.
Fill all three blanks to complete the constructor initializing three members with parameters.
class Rectangle { int width, height, area; public: Rectangle(int w, int h) : [1], [2], [3] { area = width * height; } };
w*h in the list (should be done in body)The constructor initializes width and height with parameters w and h, and sets area to 0 initially before calculating it in the constructor body.