DOC PREVIEW
UMBC CMSC 341 - CMSC341 Data Structures

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CMSC341 Data StructuresLecture 1Sept 6, 2000AdministriviaDescription– prereqs– grading– responsibilitiesSyllabusWeb page– www.cs.umbc.edu/courses/undergraduate/341/fall002ProjectsProjects– grading– due dates– honesty– submittal: cs341-04– project guidelines– project 0 -- optional– project 1 -- Due Sept 25Preview Sessions:– Wed/Thurs, Sept 6/7 8:30-9:30, SS114: C++/env– Wed/Thurs, Sept 13/14 8:30-9:30, SS114: Proj1C++ ClassClass organizes data and operations on that dataencapsulationabstractionDefinition in header file, .H (.h in MAW)Implementation in source file, .C (.cpp in MAW)#include the header file3IntCell.H#ifndef _IntCell_H_#define _IntCell_H_class IntCell {public:explicit IntCell (int initialValue = 0);IntCell (const IntCell &ic);~IntCell();const IntCell &operator=(const IntCell &rhs);int read() const; // accessorvoid write(int x); // mutatorprivate:int _storedValue;};#endifIntCell.C#include “IntCell.H”IntCell::IntCell(int initialValue) :_storedValue(initialValue){ }IntCell::IntCell (const IntCell &ic){write(ic.read());}IntCell:: ~IntCell(){ }4IntCell.C (cont)const IntCell &IntCell::operator=(const IntCell &rhs){if (this != &rhs)write (rhs.read())return *this;}int IntCell::read() const{return _storedValue;}void IntCell::write(int x){_storedValue = x;}TestIntCell.C#include “IntCell.H”#include <iostream.h> // for cout#include<stdlib.h> // for EXIT_SUCCESSint main(){IntCell m; // Or IntCell m(0);, but not IntCell m();IntCell n;n = m;m.write(5);cout << “Cell m contents: “ << m.read() << endl;cout << “Cell n contents: “ << n.read() << endl;return


View Full Document

UMBC CMSC 341 - CMSC341 Data Structures

Download CMSC341 Data Structures
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CMSC341 Data Structures and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CMSC341 Data Structures 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?