Ask Question
15 April, 11:19

Class rectangleType

{

public:

void setLengthWidth (double x, double y);

//Postcondition: length = x; width = y;

void print () const;

//Output length and width;

double area ();

//Calculate and return the area of the rectangle;

double perimeter ();

//Calculate and return the parameter;

rectangleType ();

//Postcondition: length = 0; width = 0;

rectangleType (double x, double y);

//Postcondition: length = x; width = y;

private:

double length;

double width;

};

Consider the accompanying class definition. Which of the following class variable declarations is correct?

a. rectangle rectangleType;

b. class rectangleType rectangle;

c. rectangleType rectangle;

d. rectangle rectangleType. area;

+5
Answers (1)
  1. 15 April, 13:08
    0
    rectangleType rectangle; is the following class variable declarations is correct

    c. rectangleType rectangle;

    Explanation:

    This is a class that has the definition of a rectangle and its area and perimeter and dimensions. It creates data members and member functions for the same. Now in the main (), where the execution of the program begins, to access these members and member functions a variable is needed which is called as object. An object is an instance of a class. To enable access to the members, an object is declared in the following way:

    class name object name;

    In this way, the object is created and hence can be used to access the members of the class. So, in the above class definition, the object would be created like this: rectangle Type rectangle.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Class rectangleType { public: void setLengthWidth (double x, double y); //Postcondition: length = x; width = y; void print () const; ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers