Ask Question

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. 24 May, 15:00
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers