Unformatted text preview:

OutlineC++ OverviewComparison of C and C++ExampleInsertion sortC versionOutline C++ Overview ExampleCPSC 427a: Object-Oriented ProgrammingMichael J. FischerLecture 2September 7, 2010CPSC 427a 1/9Outline C++ Overview ExampleC++ OverviewComparison of C and C++ExampleInsertion sortC versionCPSC 427a 2/9Outline C++ Overview ExampleC++ OverviewCPSC 427a 3/9Outline C++ Overview ExampleGeneral properties of C++IWidely used in the real worldIClose to the machineIGives programmer fine control over use of resoucesISupports object-oriented programming paradigmISupports modularity and component isolationISupports reusabale code through derivation and templatesCPSC 427a 4/9Outline C++ Overview ExampleC/C++ comparisonC++ Extends CIC++ grew out of C.IGoals were to improve support for modularity, portability, andcode reusability.IMost C programs will compile and run under C++.IC++ replaces several problematic C constructs with saferversions.IAlthough most old C constructs will still work in C++, theyshould not be used in new code where better alternatives exist.Example: Use Boolean constants true and false instead of1 and 0.CPSC 427a 5/9Outline C++ Overview ExampleC/C++ comparisonSome Extensions in C++IComments // (now in C99)IExecutable declarations (now in C99)IType boolIEnumerated typesIReference parametersIDefinable type conversionsIOperator extensionsIGeneric/overloaded functionsIName hidingIClassesCPSC 427a 6/9Outline C++ Overview ExampleC/C++ comparisonToolsLow-levelIA text editor such as emacs or vi.IThe compiler suite: g++.IProject management: makeEclipse IDE (integrated development environment)IIntegrates various low-level toolsIOpen sourceIWorks on many platformsIFacilitates development cycleCPSC 427a 7/9Outline C++ Overview ExampleInsertion sortGeneric Insertion SortTwo implementations of simple insertion sort:1. C version: Written in object-oriented style to the extentpossible in C.2. C++ version: Similar code but with C++ supportCPSC 427a 8/9Outline C++ Overview ExampleC versionC versionSee code demo.CPSC 427a


View Full Document

Yale CPSC 427 - Lecture 2

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