Ask Question
18 September, 06:32

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;

+3
Answers (1)
  1. 18 September, 06:46
    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?
Find an answer to your question ✅ “Class rectangleType { public: void setLengthWidth (double x, double y); //Postcondition: length = x; width = y; void print () const; ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers