DOC PREVIEW
Stanford CS 106B - Lecture Notes

This preview shows page 1-2-3-4 out of 11 pages.

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

Unformatted text preview:

Objects in C++Notes for our VisitorsDegree Production vs. Job OpeningsIntroductory Course Enrollment TrendsThere are Fewer Places to GoObjects vs. Structure TypesThe point.h InterfaceSlide 8The point.cpp ImplementationExercise: Define a Stack of CharactersThe EndObjects in C++Eric RobertsCS 106BApril 24, 2009Notes for our Visitors262 402 53.41.767 1,156 50.62.787 1,171 48.73.507 733 44.64.71 100 41.05.176 248 41.06.2 3 39.87.465 148 35.48.62 84 35.09.Network systems and data communications analystsPersonal and home care aidesHome health aidesComputer software engineers, applicationsVeterinary technologists and techniciansPersonal financial advisorsMakeup artists, theatrical and performanceMedical assistantsVeterinariansSubstance abuse and behavioral disorder counselors 83 112 34.310.Top 10 job growth categories (2006-2016) 2006 2016Employment(thousands)GrowthU.S. Department of Labor, Bureau of Labor Statistics, Employment Projections: 2006-16, December 2007.Source:Google and Facebook are fighting hard to hire this year’s crop of computer science graduates, we’ve heard, and ground zero is Stanford. Most of the class of 2008 already have job offers even though graduation is months away. Last year, salaries of up to $70,000 were common for the best students. This year, Facebook is said to be offering $92,000, and Google has increased some offers to $95,000 to get their share of graduates. Students with a Master’s degree in Computer Science are being offered as much as $130,000 for associate product manager jobs at Google.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.•The computing industry offers some of the best employment opportunities for college graduates in the United States today:–The number of jobs in the domestic software industry are at an all-time high and are projected to grow dramatically over the next decade.–Salaries for newly minted B.S. graduates in Computer Science are high, sometimes exceeding the $100,000 mark.–In 2005, Money magazine rated software engineer as the number one job in America.–Employment in this area is vital for national competitiveness.•Paradoxically, student interest in computing disciplines fell sharply between 2000 to 2006, despite high demand for graduates with those skills.•Fortunately, interest has rebounded sharply in the last year. As Steve Levy reported in the New York Times on April 12, Stanford’s enrollments in computing—and industry interest in our graduates—are as high as ever.Degree Production vs. Job Openings160,000140,000120,000100,00080,00060,00040,00020,000Engineering Physical Sciences Biological Sciences Computer SciencePh.D.Master’sBachelor’sProjected job openingsAdapted from a presentation by John Sargent, Senior Policy Analyst, Department of Commerce, at the CRA Computing Research Summit, February 23, 2004. Original sources listed as National Science Foundation/Division of Science Resources Statistics; degree data from Department of Education/National Center for Education Statistics: Integrated Postsecondary Education Data System Completions Survey; and NSF/SRS; Survey of Earned Doctorates; and Projected Annual Average Job Openings derived from Department of Commerce (Office of Technology Policy) analysis of Bureau of Labor Statistics 2002-2012 projections. See http://www.cra.org/govaffairs/content.php?cid=22.Sources:Introductory Course Enrollment Trends 0200400600800100012001400160018001985-861986-871987-881988-891989-901990-911991-921992-931993-941994-951995-961996-971997-981998-991999-002000-012001-022002-032003-042004-052005-062006-072007-082008-09projectedAll intro coursesCS106AThere are Fewer Places to GoObjects vs. Structure Types•Last week, I introduced the first example of a structure type to unify the x and y components of a point in a single value. The definition I used wasstruct pointT { int x, y;};•The problem with structure types is that it unifies values without encapsulation. The components of a pointT are visible to any part of the program that can see the type.•In modern, object-oriented programming, what you want is to hide these components within an object that then mediates the access that clients have to that information. The fields themselves are part of the private data within the class. All access to those values occurs through meth ods that are exported through the interface for that class./* * File: point.h * ------------- * This interface provides a simple class that combines the coordinates * of a point into a single object. The class Point exports a * constructor for creating a new point along with "getters" to * extract the individual components. */#ifndef _point_h#define _point_h#include "genlib.h"class Point { public:/* * Constructor: Point(x, y); * ------------------------- * This constructor creates a new Point object with the indicated values. */ Point(int x, int y);The point.h Interface/* * File: point.h * ------------- * This interface provides a simple class that combines the coordinates * of a point into a single object. The class Point exports a * constructor for creating a new point along with "getters" to * extract the individual components. */#ifndef _point_h#define _point_h#include genlib.h"class Point { public:/* * Constructor: Point(x, y); * ------------------------- * This constructor creates a new Point object with the indicated values. */ Point(int x, int y);/* * Destructor: ~Point() * -------------------- * The destructor is called when a Point is deleted or goes out of scope. */ ~Point();/* * Functions: getX(), getY() * ------------------------- * These methods returns the appropriate component. */ int getX(); int getY(); private:/* These fields are not visible to clients of the class. */ int x, y;}#endifThe point.h Interface/* * File: point.cpp * --------------- * This file implements the point.h interface. */#include "genlib.h"#include "point.h"Point::Point(int x, int y) { this->x = x; this->y = y;}Point::~Point() { /* Empty */}Point::getX() { return x;}Point::getY(); return y;}The point.cpp ImplementationExercise: Define a Stack of Characters•Write a class that implements the basic stack functions for a stack that contains characters. This exercise will introduce several design


View Full Document

Stanford CS 106B - Lecture Notes

Download Lecture Notes
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 Lecture Notes 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 Lecture Notes 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?