DOC PREVIEW
Yale CPSC 427 - Object-Oriented Programming
School name Yale University
Pages 18

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 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 18 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 18 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 18 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 18 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 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

OutlineRemarks on Laboratory WorkReview and ReadingsMore on C++ I/OOutline Remarks on Laboratory Work Review and Readings More on C++ I/OCPSC 427a: Object-Oriented ProgrammingMichael J. FischerLecture 4September 14, 2010CPSC 427a 1/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/ORemarks on Laboratory WorkReview and ReadingsMore on C++ I/OCPSC 427a 2/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/ORemarks on Laboratory WorkCPSC 427a 3/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OToolset to use for course workThis course uses a collection of software tools running under Linux,including g++, valgrind, eclipse, make, a command shell suchas bash or tcsh, and Linux libraries and header files.These and other tools you will need are installed and maintainedon the Zoo machines.You are all entitled to Zoo accounts for use in this course, and youwill all be granted 24-hour access to the Zoo (in Arthur K. WatsonHall). I expect you to use the Zoo for all course work.CPSC 427a 4/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OWorking remotelyFor those of you who find it difficult to get to the Zoo and want towork remotely, I offer three suggestions, all of which have somedrawbacks.CPSC 427a 5/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/O1. Replicate the Zoo environment on your own machineThis means installing Linux, either in place of your nativeoperating system, beside it in a dual-boot arrangement, or on topof it using virtualization software.Drawbacks: It takes time and expertise to install and configure allof the software you will need, and there is still the danger ofincompatabilities with the Zoo if you don’t end up with exactly thesame versions of everything.CPSC 427a 6/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/O2. Remote login to the ZooLog into the Zoo remotely via ssh (which you must install on yourmachine), and use command-line tools such as emacs and make todevelop your code.Drawbacks: People used to program using command-line tools, butit is cumbersome compared with using a modern graphicalwindowing system and an IDE such as eclipse.CPSC 427a 7/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/O3. Set up a virtual Zoo desktop on your machineTo use VNC (Virtual Network Computing), you must:1. install SSH and VNC clients on your machine;2. log onto a Zoo machine using ssh;3. start a VNC server on the Zoo;4. connect to the VNC server using your VNC client.See handout 2 (pdf) for detailed instructions.VNC gives you a virtual Zoo desktop that, in principle,will lookand feel just as if you were sitting at a Zoo console.Drawbacks: It won’t really feel the same. You will notice delayedresponse to your mouse actions. It’s a bit of a nuisance getting theconnection set up each time you want to work. Moving files backand forth between your local machine and the Zoo requires othertools such as rsync or scp.CPSC 427a 8/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OHomework submissionCompleted homework is to be submitted on the Zoo using thecommand /c/cs427/bin/submit.In order to submit, you must have a course account.Put the files you want to submit into a subdirectory, go to thatdirectory, and run submit.The first argument to submit is the problem set number.The remaining arguments are the files to be submitted.Example: submit 1 * submits everything in the current directoryfor problem set #1.CPSC 427a 9/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OReview and ReadingsCPSC 427a 10/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OA brief course review to dateLecture 1 describes the course goals of how to constructsoftware that is efficient, robust, scalable,maintainable, reusable, and understandable, as wellas giving correct outputs on correct inputs.Lecture 2 looks at how object-oriented design principles can beapplied even to C programs, pointing out alsoinherent limitations of C that motivated thedevelopment of C++.Lecture 3 gives a whirlwind tour of an object-oriented C++program for insertion sort, looking in particular athow the various pieces of code are split into interfaceor header files (.hpp) and implementation or codefiles (.cpp).CPSC 427a 11/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OHow to use the textbookThe lectures do not exactly follow the textbook, but they areroughly parallel.For example, lectures 1–3 generally correspond to chapters 1 and2, although several concepts from chapters 3 and 4 were alsocovered briefly.You should read the corresponding chapters carefully, becausethere is information in the book that will not be covered explicitlyin class but that you should nevertheless know.CPSC 427a 12/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OMore on C++ I/OCPSC 427a 13/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OOpening and closing streamsSome ways of opening a stream.Iifstream fin ( "myfile.in" ); opens stream fin forreading. This implicitly invokes the constructor ifstream("myfile.in" ).Iifstream fin; creates an input stream not associated witha file. fin.open( "myfile.in" ); attaches it to a file.Can also specify open modes.To close, use fin.close();.CPSC 427a 14/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OReading dataSimple forms. Assume fin is an open input stream.Ifin >> x >> y >> z; reads three fields from fin into x,y, and z.IThe kind of input conversion depends on the types of thevariables.INo need for format or &.IStandard input is called cin.ICan read a line into a buffer with fin.get(buf, buflen);.This function stops before the newline is read. To continue,one must move past the newline with a simple fin.get(ch);or fin.ignore();.CPSC 427a 15/18Outline Remarks on Laboratory Work Review and Readings More on C++ I/OWriting dataSimple forms. Assume fout is an open output stream.Ifout << x << y << z; writes x, y, and z into fout.IThe kind of output conversion depends on the types of thevariables or expressions..IStandard output is called cout. Other predefined outputstreams are cerr and clog. They are usually initialized tostandard output but can be redirected.IWarning: The eclipse debug window does not obey the propersynchronization rules when displaying cout and cerr. Rather,the output lines are


View Full Document

Yale CPSC 427 - Object-Oriented Programming

Download Object-Oriented Programming
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 Object-Oriented Programming 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 Object-Oriented Programming 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?