. Ex4 – preliminary feedback. Comments on Ex4 Cautionary note: u These are observations on some of the submitted exercises u The emphasis is to explain.

Slides:



Advertisements
Similar presentations
Chapter 18 Vectors and Arrays
Advertisements

A C++ Crash Course Part II UW Association for Computing Machinery Questions & Feedback.
Object Oriented Programming Lect. Dr. Daniel POP Universitatea de Vest din Timişoara Facultatea de Matematică şi Informatică.
CSE 332: C++ overview CSE 332 Overview and Structure CSE 332 emphasizes studio-based active learning –Introductory lecture material followed by hands-on.
. STL: C++ Standard Library (continued). STL Iterators u Iterators are allow to traverse sequences u Methods  operator*  operator->  operator++, and.
Introduction to Programming Lecture 39. Copy Constructor.
C++ Programming Languages
CPA: C++ Polymorphism Copyright © 2007 Mohamed Iqbal Pallipurath Overview of C++ Polymorphism Two main kinds of types in C++: native and user-defined –User-defined.
Lecture 3 Feb 4 summary of last week’s topics and review questions (handout) Today’s goals: Chapter 1 overview (sections 1.4 to 1.6) c++ classes constructors,
. Templates. Example… A useful routine to have is void Swap( int& a, int &b ) { int tmp = a; a = b; b = tmp; }
Overview CS113, Fall 2000 Gene Itkis. The Promise Heavy Fast-paced Challenging Rewarding.
. The Standard C++ Library. 2 Main Ideas Purpose Flexibility Efficiency Simple & Uniform Interface.
Rossella Lau Lecture 8, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 8: Polymorphism & C++ pointer  Inheritance.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++
Templates. Example… A useful routine to have is void swap(int &a, int &b){ int tmp = a; a = b; b = tmp; }
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
OOP Languages: Java vs C++
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
Object Oriented Programming using C++. Overview Problem Solving Features of an OOL Basic Syntax Programming Paradigms.
C++ C++ Overview (I) What is Object Orientated Programming? Approach: Break problem into subgroups of related parts that take into account code and data;
CSE 333 – SECTION 4. Overview Pointers vs. references Const Classes, constructors, new, delete, etc. More operator overloading.
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Data Structures Using C++ 2E
C# Programming Fundamentals of Object-Oriented Programming Fundamentals of Object-Oriented Programming Introducing Microsoft.NET Introducing Microsoft.NET.
C++
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
Generic Programming Using the C++ Standard Template Library.
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
1. The term STL stands for ? a) Simple Template Library b) Static Template Library c) Single Type Based Library d) Standard Template Library Answer : d.
Introducing Allors Applications, Tools & Platform.
C++ Review Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Acknowledgement: Adapted from: Brown.
CMSC 202, Version 3/02 1 Copy Constructors and Overloaded Assignment.
Overview of C++ Templates
OOP in C++ CS 124. Program Structure C++ Program: collection of files Source (.cpp) files be compiled separately to be linked into an executable Files.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Cramming for CS 247. FAQ Q: Will you post these slides online? A: Yes.
Principles of Object-Oriented Software Development The language C++
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (next Friday). After today you should know everything you need for assignment.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Chapter 3 Templates. Objective In Chapter 3, we will discuss: The concept of a template Function templates Class templates vector and matrix classes Fancy.
Copyright © 2009 – Curt Hill Standard Template Library An Introduction.
Overview of C++ Polymorphism
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (this Friday). Today: –Templates. –STL –Smart Pointers.
Singleton Academy, Pune. Course syllabus Singleton Academy Pune – Course Syllabus1.
Features of.net Language independent Object oriented program Multi threading Exception handling Drag and drop Linq
CSE 332: C++ Overloading Overview of C++ Overloading Overloading occurs when the same operator or function name is used with different signatures Both.
CS 100Lecture 231 Announcements Check your grades on the door of 5141 Upson More review tomorrow Review session Sunday night w/Alan FINAL EXAM: Tuesday.
Mind Q Systems Leader s In Training /7, 2nd Floor, Srinivasa Nagar Colony (W) Above HDFC Bank, S.R. Nagar Hyderabad Tel: /92.
Object-Oriented Programming Review 1. Object-Oriented Programming Object-Oriented Programming languages vary but generally all support the following features:
Chapter 2 Objects and Classes
Regarding homework 9 Many low grades
Introduction to Computers Computer Generations
CSE 332 Overview and Structure
Object-Oriented Programming (OOP) Lecture No. 45
C++, OBJECT ORIENTED PROGRAMMING
Object-Orientated Programming
CSE 332 Overview and Structure
CSE 332 Overview and Structure
Concurrency Wrap-Up & Final Review
OBJECT-ORIENTED PROGRAMMING
Containers and the Standard Template Library (STL)
CSE 333 – Section 10 Final Review.
Objects Managing a Resource
Overview of C++ Polymorphism
Presentation transcript:

. Ex4 – preliminary feedback

Comments on Ex4 Cautionary note: u These are observations on some of the submitted exercises u The emphasis is to explain some issues and hopefully teach you something u This is not a statement of things that need to be fixed for ex5

Design issue #1: Graph operations class Graph { … Graph* operator+(Graph const& rhs) const; }; vs. class Graph { … }; Graph *graphUnion( Graph const&, Graph const& );

Design issue #2: Encapsulation What is wrong with this? class Graph { public: typedef map VerticesMap; … VerticesMap const& vertices(); … };

Design issue #3: iterators u Using STL iterators is perfectly ok class Graph { public: … typedef map ::iterator iterator; iterator begin(); iterator end(); private: map m_Vertices; };

Design issue #4: iterators (again) class Graph { vertex* findVertex( string const& name ); } vs. class Graph { iterator findVertex( string const& name ); }

Design Issue #5: Iterators (last) u Iterators are supposed to be light-weight u This is not a good example class GraphVerticesIterator { private: Graph* mGraph; Graph::VerticeMap::iterator mi; Graph::VerticeMap::iterator mBegin,mEnd; };

Design issue #6: Interface u Graph as a collection of vertices string v1, v2 … graph.findVertex(v1).addEdge(v2); vs. u Graph as a “unified” data structure graph.addEdge(v1,v2);

Design Issue #7: Interfaces class vertex { … addIncomingEdge( string const& from ); addOutgoingEdge( string const& to ); }; class Graph { … void addEdge( string const& from, string const& to ) { … // various checks… mEdges.add( Edge(from, to) ); findVertex( from )->addOutgoingEdge( to ); findVertex( to )->addOutgoingEdge( from ); } };

. Summary

What Have We Learned? u C:  Basic language  Motto: “Simple does it”  Lean (& mean) u C++  High level constructs  Complex type system  Extensive libraray u Practice of Programming

C – Language u Architecture  Preprocessor/Complier/Linker  Memory structure & organization  Libraries (static/shared)  Makefiles

C – Language u Basic language constructs:  Basic types  Arrays  Functions

C - language u “Complex” language constructs  pointers  memory management: malloc/free  pointers to functions  const

C - language Standard library  I/O: printf/scanfs  String functions  qsort  binary search  random  atof/atoi

C++ - language u Object oriented programming  Classes  Constructors & destructors  Inheritance  Polymorphism – virtual functions, pure virtual classes  this  Encapsulation (private/protected/public/friend)

C++ - language u Advanced features  Function & operator overloading  Function resolution  Reference  RTTI  Exceptions  inline  static

C++ - language u Generic programming  Templates  STL  Using STL interface (iterators)

C++ - Language u Pointers & memory  new/delete  encapsulation of resources  copy ctor, assignment op  smart pointers

Practice of Programming u Programming style u Testing u Debugging u Performance u emacs u Makefile u Programming with interfaces u Design patterns