{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Quiz 8 and Solutions

# Quiz 8 and Solutions - public Circle Circle(double x_pos...

This preview shows pages 1–3. Sign up to view the full content.

Computer Techniques for Electronic Design II (ESE 224) Quiz for chapter 8 Period: 10 minutes Multiple Choices 1. Which of the following statements about CLASS are true? a) An object is an instance of a CLASS. b) Data members of a class must be of the same data type. c) A semicolon is required following the body of a CLASS declaration. d) A class declaration should be placed in a separate .h file. e) A class implementation should be placed in a separated .cpp file. 2. Which of following statements about CLASS functions are true? a) All functions declared in a CLASS definition are member functions. b) Constructor functions are member functions. c) All member functions could be overloaded. d) Functions specified as “PRIVATE” cannot be called by non member functions/classes. e) Only PRIVATE functions could access all data members of a CLASS. Memory Snapshot Problem // Class Declaration class Circle {

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public: Circle(); Circle(double x_pos, double y_pos, double radius_val); double measure(); double distance(); private: double x, y; double radius; double pi; }; // Class Implementation Circle::Circle(): x(0),y(1),radius(1) { pi = 3.1415926; } Circle::Circle(double x_pos, double y_pos, double radius_val): x(x_pos), y(y_pos), radius(radius_val) { pi = 3.1415926; } double Circle::distance() { return (x-0)*(x-0) + (y – 0) *(y – 0); } 3. Double a, b; Circle c1, c2; a = c1.distance(); b = c2.distance(); What is the value of a and b? 4. Double a, b; Circle c1(1,2,1), c2(2,1,2); a = c1.distance(); b = c2.distance(); What is the value of a and b? 5. Implement the function measure() (Area) to compute the measure of the circle using pi defined in the class. Solutions 1. A, C, D, E 2. A, B, C, D 3. a = b = 1; 4. a = b = 5; 5. double Circle::measure() { return pi * radius * radius; }...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

Quiz 8 and Solutions - public Circle Circle(double x_pos...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online