CSE 283 Introduction to Object Oriented Design

Barbara Nostrand, Ph.D.

CSE 283 Labs
Welcome to the site for CSE 283 Labs!


Lab 2: C++ Project

Prev | Next | Lab 2



1. Practice using the text editor and C++ compiler.
2. Gain experience with sequential programming.
3. Practice using the I/O facilities.


Like Java,  C++ supports class definitions.  However,  we will discover a number of differences between classes in Java and Classes in C++.  Our first difference is in how access is controlled in the two languages.  In Java,  access rights are directly attached to each class,  variable,  and method declaration.  In C++,  the declarations in each class are broken into sections according to access rights: 

class My_Class
   // function declarations typically go here
   // attribute declarations typically go here
Notice also that class declarations in C++ end with a semicolon. 

Classes in C++ While Java is strictly an object-oriented language,  C++ is an extention to the C language which supports objects and object-oriented programming.  While Java programs consist of files containing class declarations,  class class declarations in C++ are usually stored in auxiliary include files ending with a .h extension. 

C++ Math Library Functions

Like Java,  C++ has a standard mathematical library.  The declarations for this library are stored in a system library directory.  Consequently,  you need to tell the compiler to include them before they can be used.  This is accomplished by inserting the following line into your source code:

	#include <cstdlib>
abs(x)Absolute value of real value x
pow(x, y)x raised to the y power
sqrt(x)Square root of x
ceil(x)Least integer greater than or equal to x
floor(x)Greatest integer less than or equal to x
exp(x)Exponential function ex
log(x)Natural logarithm of x
log10(x)Base 10 logarithm of x
sin(x)Sine of x in radians
cos(x)Cosine of x in radians
tan(x)Tangent of x in radians
asin(x)Inverse sine of x
qcos(x)Inverse cosine of x in radians
atan(x)Inverse tangent of x in radians
sinh(x)Hyperbolic sine of x
cosh(x)Hyperbolic cosine of x in radians
tanh(x)Hyperbolic tangent of x in radians


Implement a version of Sphere in C++.  Your C++ version of Sphere need not produce a GUI interface.  Like Java,  C++ is case-sensitive.  Named constants are given all in uppercase.  The words in multi-word constant names are separated by underscore characters.  Be sure to declare the named constant PI

const double PI = 3.1415926;

Don't forget to clean up your directory when you are all finished. 

Prev | Next | Lab 2




Lab 0

Lab 1

Lab 2

Lab 3

Lab 4

Lab 5

Lab 6

Lab 7-8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13

Last modified: 2007 OCT 28