class Rectangle { public: void setLenthWidth (double x, double y); //Postconditi
ID: 3653280 • Letter: C
Question
class Rectangle { public: void setLenthWidth (double x, double y); //Postcondition: length = x; width = y; void print() const; //Output length and width; double area() const; //Calculte and return the area of the retangle; double perimeter() const; //Calculate and retur the parameter; Rectangle (); //Postcondition: length = 0; width = 0; Rectangle (double x, double y); //Postcondition: length = x; width = y; private: double length; double width; }; Which of the following class variable declarations is correct? A. myrectangle Rectangle; B. class Rectangle myrectangle; C. Rectangle myrectangle; D. myrectangle Rectangle.area; Please explainExplanation / Answer
please rate - thanks
class Rectangle
{ public:
void setLenthWidth (double x, double y); //Postcondition: length = x; width = y;
void print() const; //Output length and width;
double area() const; //Calculte and return the area of the retangle;
double perimeter() const; //Calculate and retur the parameter;
Rectangle (); //Postcondition: length = 0; width = 0;
Rectangle (double x, double y); //Postcondition: length = x; width = y;
private: double length; double width;
};
A. myrectangle Rectangle;
B. class Rectangle myrectangle;
C. Rectangle myrectangle;
D. myrectangle Rectangle.area;
explanation:
just as you would declare a variable of type integer
you are declaring a variable but this is of type Rectangle.
so a type declaration is in the form
type variable name
so the type is Rectangle, the variable name is myrectangle
so the declaration is
Rectangle myrectangle;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.