Transition from C to C and a Review
- Slides: 20
Transition from C to C++ …and a Review of Basic Problem Solving
Why Switch to C++ • To pass this class. ; -) • To get a job (or “Everyone else is doing it…”) • Path of least resistance to OOP • Nicer I/O model • Better comment format
Why Switch to C++ (cont’d) • Supports an OO approach to programming – Classes – Inheritance – Polymorphism – Exceptions • Provides powerful features on top of a “fast” language
How to Switch to C++ 1. Learn about differences a. New tools (compilers, debuggers, etc. ) b. New libraries c. New file naming conventions d. New syntax e. Available standards 2. Rethink programming approach
1 a. New Tools for C++ • Compiler: g++ or CC (CC is only on the SGIs) • Debugger: gdb, dbx (SGI), cvd (SGI), or printf(). ; -) • Some text editors “understand” C++. (formatting, syntax highlighting)
1 b. New Libraries for C++ • All of the C libraries still work! • Some C++ specific libraries will be introduced throughout the semester.
1 c. New File Naming Conventions for C++ • Some conventions for file names – foo. H, foo. C – foo. hh, foo. cc – Also foo. cpp, foo. cxx • Conventions for source code are on the course web page under Coding Standards
1 d. New Syntax • Syntax virtually identical to C – C++’s features add syntax • More on syntax throughout the semester
1 e. Available Standards • ISO/IEC 14882 in 1997 – Adopted ANSI in 1998
2. Rethinking Programming Approach • Programming languages provide tools – Tools are your language to solve problems – Learn to work with them, not against them – Use the idioms of the language
Some questions about C • What is C? – C is a low-level, procedural, systems programming language. • What problem did C solve? • Designed as a system’s programming language for UNIX in the 1970 s • A fast, flexible, low-level language was needed.
Some Questions about C++ • What is C++? – C++ is an extension of C that provides support for object-oriented programming. • What problem did it solve? – Stroustrup states, “I built C++ as a bridge over which people would pass from traditional programming to styles relying on data abstraction and object-oriented programming. ”
Procedural vs. Object-oriented • Procedural Programming – Program execution is a series of “procedures” operating on data. – Procedures (or “operations”) and data are separate constructs. • Object-oriented Programming – Program execution is a series of object interactions. – Data and operations on those data belong together as a single unit.
Why OOP? • OOP was “discovered” in the 1960 s: – The Simula project • Collections of variables and procedures for “natural units of programming”.
Goals of Software Development • When developing software, we strive for software that is: – Correct (meets requirements) – Reliable (bug free) – Easily maintained (corrections and upgrades) – Reusable
C++ for Software Development • As an “object-oriented” language, C++ helps create – Reusable code – More easily maintained code • Bad programmers will still write bad programs.
Problem Solving (A Review)
Tools for Problem Solving 1. Defining the problem (WHAT) • Formalization 2. Developing a solution (HOW) – Creativity – Decomposition
1. Defining the problem • Formalize the problem – Name it – If you can’t formalize it, you don’t understand it • Make your program solve the problem at hand (or a more general version of the same problem) • Constraints are part of the problem too! – Time – $$$ – Other Resources (memory, etc. )
2. Developing a solution • Creativity – Creative != “Slick” • Decomposition – Top down design – Every problem consists of subproblems. • Decompose your problem into its subproblems, then repeat on each subproblem. • Understand the interaction of the subproblems, then solve them one by one.
- Chapter review motion part a vocabulary review answer key
- Uncontrollable spending ap gov
- Narrative review vs systematic review
- Inclusion criteria examples
- Narrative review vs systematic review
- Text structure transition words
- Transition words to start a paragraph
- How to write a topic sentence example
- It is the transition area between soil and parent material
- Difference between transition state and intermediate
- Change and transition difference
- Hook transition thesis
- Mutation and polymorphism
- Transition words for compare and contrast
- Compare and contrast essay words
- Difference between rigid and flexible pavement
- Naverageat
- Cause and effect transition words
- Adam hayes and hopson
- Concessions and refutations
- Difference between change and transition