(C++ only) Class practice 1


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C++

This practice problem will require you to implement member functions of a class.

Before you get started, please download Handout H804 and find the following files:

p022.h
demo4.cpp

Here, you are required to write p022.cpp and implement member functions in the Circle class in p022.h, just like we did in class.

The two member functions:

  1. void setRadius(double val); should set the private member variable radius to the value of val.

  2. double area(); should output the area of the circle given its radius (private member). Use the provided constant pi.

For testing, compile the header using demo4.cpp as your main programme. Do not use other methods.

After you are done, upload the content of your p022.cpp on the OJ here.

Input Specification

No input specification. OJ will automatically judge your implementation of p022.cpp.

Output Specification

No output specification. OJ will automatically judge your implementation of p022.cpp.


Comments

There are no comments at the moment.