(C++ only) Class practice 1
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:
void setRadius(double val);
should set the private member variableradius
to the value ofval
.double area();
should output the area of the circle given itsradius
(private member). Use the provided constantpi
.
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