Ecole Nationale d Ingénieurs de Brest. Programmation par objets Le langage C++ Type Concret de Données en C++
|
|
- Everett Wright
- 6 years ago
- Views:
Transcription
1 Notes de cours Ecole Nationale d Ingénieurs de Brest Programmation par objets Le langage C++ Type Concret de Données en C++ J. Tisseau 1995/1997 enib c jt /30
2 Du TAD au TCD Type Abstrait de Données + Choix d une représentation physique + Implémentation dans le langage cible = Type Concret de Données enib c jt /30
3 Type Abstrait de Données Type Abstrait de Données + Choix d une représentation physique + Implémentation dans le langage cible = Type Concret de Données enib c jt /30
4 Le TAD Array[T] (t 1, t 2,..., t i, t i+1,..., t n ) Un tableau (Array[T]) est une suite finie et ordonnée d éléments (de type T) accessibles par un indice entier (Integer). Les éléments sont ordonnés dans l ordre croissant des indices. Deux éléments successifs correspondent à des indices successifs (..., t i, t i+1,... ). Le premier élément a l indice 1. enib c jt /30
5 Les services du TAD Array[T] Inspectors : empty : Array[T] Boolean full : Array[T] Boolean size : Array[T] Integer capacity : Array[T] Integer element : Array[T] Integer T Modifiers : setelement : Array[T] Integer T Array[T] insert : Array[T] Integer T Array[T] erase : Array[T] Integer Array[T] enib c jt /30
6 Les preconditions du TAD Array[T] Preconditions : array Array[T], n Integer, t T element(array,n) est défini si et seulement si ( empty(array)) (1 n size(array)) setelement(array,n,t) est défini si et seulement si ( empty(array)) (1 n size(array)) insert(array,n,t) est défini si et seulement si ( full(array)) (1 n (size(array) + 1)) erase(array,n) est défini si et seulement si ( empty(array)) (1 n size(array)) enib c jt /30
7 Les axiomes du TAD Array[T] Axioms : array Array[T], n Integer, t T empty(array) (size(array) = 0) full(array) (size(array) = capacity(array)) ( empty(array)) (1 n size(array)) (size(erase(array,n)) = size(array) - 1) ( full(array)) (1 n (size(array) + 1)) (size(insert(array,n,t)) = size(array) + 1) enib c jt /30
8 Les axiomes du TAD Array[T] Axioms : array Array[T], n,i Integer, t T ( empty(array)) (1 n size(array)) (1 i < n) (element(erase(array,n),i) = element(array,i)) ( empty(array)) (1 n size(array)) (n i (size(array) - 1)) (element(erase(array,n),i) = element(array,i + 1)) enib c jt /30
9 Les axiomes du TAD Array[T] Axioms : array Array[T], n,i Integer, t T ( full(array)) (1 n size(array) + 1) (1 i < n) (element(insert(array,n,t),i) = element(array,i)) ( full(array)) (1 n size(array) + 1) (i = n) (element(insert(array,n,t),i) = t) ( full(array)) (1 n size(array) + 1) (n < i size(array) + 1) (element(insert(array,n,t),i) = element(array,i-1)) enib c jt /30
10 Choix d une représentation physique Type Abstrait de Données + Choix d une représentation physique + Implémentation dans le langage cible = Type Concret de Données enib c jt /30
11 Tableau dynamique capacity { }} { array t 1 t 2 t 3 }{{} size enib c jt /30
12 Implémentation dans le langage cible Type Abstrait de Données + Choix d une représentation physique + Implémentation dans le langage cible = Type Concret de Données enib c jt /30
13 L interface de la classe Array<T> // file Array.h #ifndef ARRAY H #define ARRAY H #include <stdlib.h> #include <iostream.h> #include <stl/bool.h> // size t // ostream // bool enib c jt /30
14 L interface de la classe Array<T> template <class T> class Array { public: // Allocators Array(size t capacity = 0); Array(const Array<T>& array); Array& operator=(const Array<T>& array); virtual ~Array(void); // Output friend ostream& operator<<(ostream& stream, const Array<T>& array); enib c jt /30
15 L interface de la classe Array<T> public: // Inspectors size t size(void) const; size t capacity(void) const; bool empty(void) const; bool full(void) const; const T& element(size t n) const; // Comparisons bool operator==(const Array<T>& array) const; bool operator!=(const Array<T>& array) const; enib c jt /30
16 L interface de la classe Array<T> public: // Modifiers void setelement(size t n, const T& t); void insert(size t n, const T& t); void erase(size t n); // Accessors const T& operator[](size t n) const; T& operator[](size t n); enib c jt /30
17 L interface de la classe Array<T> private: // Attributes size t capacity; // capacité du tableau size t size; // nombre d éléments du tableau T* array; // tableau C dynamique }; #endif // end of file Array.h enib c jt /30
18 L implémentation de la classe Array<T> // file Array.C #include <assert.h> #include "Array.h" template <class T> Array<T>::Array(size t capacity) : capacity(capacity), size(0), array(new T[ capacity]) {} template <class T> Array<T>::~Array(void) { if( array) delete [] array; } enib c jt /30
19 L implémentation de la classe Array<T> template <class T> Array<T>::Array(const Array<T>& array) : capacity(array. capacity), size(array. size), array(new T[ capacity]) { for(size t i = 0; i < size; i++) array[i] = array. array[i]; } enib c jt /30
20 L implémentation de la classe Array<T> template <class T> Array& Array<T>::operator=(const Array<T>& array) { if(this!= &) { if( array) delete [] array; capacity = array. capacity; size = array. size; array = new T[ capacity]; for(size t i = 0; i < size; i++) } array[i] = array. array[i]; } return *this; enib c jt /30
21 L implémentation de la classe Array<T> template <class T> ostream& operator<<(ostream& stream, const Array<T>& array) { stream << ( ; if(!array.empty()) { for(size t i = 0; i < array.size() - 1; i++) stream << array.element(i) <<, ; stream << array.element(array.size() - 1); } return stream << ) ; } enib c jt /30
22 L implémentation de la classe Array<T> template <class T> size t Array<T>::size(void) const { return size; } template <class T> size t Array<T>::capacity(void) const { return capacity; } template <class T> bool Array<T>::empty(void) const { return size == 0; } template <class T> bool Array<T>::full(void) const { return size == capacity; } enib c jt /30
23 L implémentation de la classe Array<T> template <class T> const T& Array<T>::element(size t n) const { assert((!empty()) && (n >= 0) && (n < size())); return array[n]; } template <class T> void Array<T>::setElement(size t n, const T& t) { assert((!empty()) && (n >= 0) && (n < size())); array[n] = t; } enib c jt /30
24 L implémentation de la classe Array<T> template <class T> void Array<T>::insert(size t n, const T& t) { assert((!full()) && (n >= 0) && (n <= size())); for(size t i = size(); i > n; i--) array[i] = array[i-1]; array[n] = t; size++; } enib c jt /30
25 L implémentation de la classe Array<T> template <class T> void Array<T>::erase(size t n) { assert((!empty()) && (n >= 0) && (n < size())); for(size t i = n; i < size(); i++) array[i] = array[i+1]; size--; } enib c jt /30
26 L implémentation de la classe Array<T> template <class T> const T& Array<T>::operator[](size t n) const { assert((!empty()) && (n >= 0) && (n < size())); return array[n]; } template <class T> T& Array<T>::operator[](size t n) { assert((!empty()) && (n >= 0) && (n < size())); return array[n]; } enib c jt /30
27 L utilisation de la classe Array<T> // Main.C #include "Array.h" void main(void) { Array<int> array(10); int x = 1; while((x!= 0) && (!array.full())) { cout << "> "; cin >> x; array.insert(0,x); } while(!array.empty()) { cout << array.element(0) << endl; array.erase(0); } } enib c jt /30
28 L utilisation de la classe Array<T> # makefile Main : Array.o Main.o CC Array.o Main.o -o Main Array.o : Array.h Array.C CC -c Array.C Main.o : Array.h Main.C CC -c Main.C enib c jt /30
29 L utilisation de la classe Array<T> $ make $ Main > 1 > 2 > $ CC -c Array.C CC -c Main.C CC Array.o Main.o -o Main enib c jt /30
30 Bibliographie Carroll, Ellis M.J. Designing reusable C++, Addison Wesley, 1995 Coplien J.O. Programmation avancée en C++ : styles et idiomes, Addison Wesley, 1992 Lippman S.B. Le modèle objets du C++, International Thomson Publishing, 1997 Stroustrup B. Le langage C++, Addison Wesley, 1992 enib c jt /30
Due Date: See Blackboard
Source File: ~/2315/11/lab11.(C CPP cpp c++ cc cxx cp) Input: Under control of main function Output: Under control of main function Value: 1 The purpose of this assignment is to become more familiar with
More informationComp151. Generic Programming: Container Classes
Comp151 Generic Programming: Container Classes Container Classes Container classes are a typical use for class templates, since we need container classes for objects of many different types, and the types
More informationReview: C++ Basic Concepts. Dr. Yingwu Zhu
Review: C++ Basic Concepts Dr. Yingwu Zhu Outline C++ class declaration Constructor Overloading functions Overloading operators Destructor Redundant declaration A Real-World Example Question #1: How to
More informationDue Date: See Blackboard
Source File: ~/2315/45/lab45.(C CPP cpp c++ cc cxx cp) Input: under control of main function Output: under control of main function Value: 4 Integer data is usually represented in a single word on a computer.
More informationclass Array; // Class template declaration class Array public: // T="type",e.g.,int or float Array(int n); // Create array of n elements Array(); // C
LECTURE 5 Templates We have written a simple array class of oat variables. But suppose we want to have arrays of integers, or doubles, or something else. It's a pain to write a separate array class for
More informationAbstract Data Types (ADT) and C++ Classes
Abstract Data Types (ADT) and C++ Classes 1-15-2013 Abstract Data Types (ADT) & UML C++ Class definition & implementation constructors, accessors & modifiers overloading operators friend functions HW#1
More informationEINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics and Computer Science
EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics and Computer Science Written examination Homologation C++ and Computer Organization (2DMW00) Part I: C++ - on Tuesday, November 1st 2016, 9:00h-12:00h.
More informationpointers & references
pointers & references 1-22-2013 Inline Functions References & Pointers Arrays & Vectors HW#1 posted due: today Quiz Thursday, 1/24 // point.h #ifndef POINT_H_ #define POINT_H_ #include using
More informationCSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.
Name: CSE 303, Winter 2007, Final Examination 15 March 2007 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for two 8.5x11in pieces of paper (both
More informationSet Implementation Version 1
Introduction to System Programming 234122 Set Implementation Version 1 Masha Nikolski, CS Department, Technion 1 // Version 1.0 2 // Header file for set class. 3 // In this implementation set is a container
More informationLab 2: ADT Design & Implementation
Lab 2: ADT Design & Implementation By Dr. Yingwu Zhu, Seattle University 1. Goals In this lab, you are required to use a dynamic array to design and implement an ADT SortedList that maintains a sorted
More informationDue Date: See Blackboard
Source File: ~/2305/lab06.(C CPP cpp c++ cc cxx cp) Input: Under control of main function Output: Under control of main function Value: 2 Extend the IntegerSet class from Lab 04 to provide the following
More informationการทดลองท 8_2 Editor Buffer Array Implementation
การทดลองท 8_2 Editor Buffer Array Implementation * File: buffer.h * -------------- * This file defines the interface for the EditorBuffer class. #ifndef _buffer_h #define _buffer_h * Class: EditorBuffer
More informationMore Advanced Class Concepts
More Advanced Class Concepts Operator overloading Inheritance Templates PH (RH) (Roger.Henriksson@cs.lth.se) C++ Programming 2016/17 146 / 281 Operator Overloading In most programming languages some operators
More informationSFU CMPT Topic: Class Templates
SFU CMPT-212 2008-1 1 Topic: Class Templates SFU CMPT-212 2008-1 Topic: Class Templates Ján Maňuch E-mail: jmanuch@sfu.ca Monday 3 rd March, 2008 SFU CMPT-212 2008-1 2 Topic: Class Templates Class templates
More informationCSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.
Name: CSE 303, Winter 2007, Final Examination 15 March 2007 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for two 8.5x11in pieces of paper (both
More informationDue Date: See Blackboard
Source File: ~/2315/06/lab06.(C CPP cpp c++ cc cxx cp) Input: Under control of main function Output: Under control of main function Value: 2 Extend the IntegerSet class from Lab 04 to provide the following
More informationEECE.3220: Data Structures Spring 2017
EECE.3220: Data Structures Spring 2017 Lecture 14: Key Questions February 24, 2017 1. Describe the characteristics of an ADT to store a list. 2. What data members would be necessary for a static array-based
More informationADTs & Classes. An introduction
ADTs & Classes An introduction Quick review of OOP Object: combination of: data structures (describe object attributes) functions (describe object behaviors) Class: C++ mechanism used to represent an object
More informationGENERIC PROGRAMMING IN C++
Proceedings of the South Dakota Academy of Science, Vol. 78 (1999) 91 GENERIC PROGRAMMING IN C++ Catherine Van Note and Stephen Shum Computer Science Department Augustana College Sioux Falls, SD 57197
More informationCours de C++ Introduction
Cours de C++ Introduction Cécile Braunstein cecile.braunstein@lip6.fr Cours de C++ 1 / 20 Généralité Notes Interros cours 1/3 Contrôle TP 1/3 Mini-projet 1/3 Bonus (Note de Participation) jusqu à 2 points
More informationObject oriented programming
Exercises 12 Version 1.0, 9 May, 2017 Table of Contents 1. Virtual destructor and example problems...................................... 1 1.1. Virtual destructor.......................................................
More informationObject oriented programming
Exercises 6 Version 1.0, 21 March, 2017 Table of Contents 1. Operators overloading....................................................... 1 1.1. Example 1..............................................................
More informationDue Date: See Blackboard
Source File: ~/2315/04/lab04.(C CPP cpp c++ cc cxx cp) Input: Under control of main function Output: Under control of main function Value: 3 In this assignment create an IntegerSet class that will provide
More informationSearching Algorithms. Chapter 11
Data Structures Dr Ahmed Rafat Abas Computer Science Dept, Faculty of Computer and Information, Zagazig University arabas@zu.edu.eg http://www.arsaliem.faculty.zu.edu.eg/ Searching Algorithms Chapter 11
More informationCircle all of the following which would make sense as the function prototype.
Student ID: Lab Section: This test is closed book, closed notes. Points for each question are shown inside [ ] brackets at the beginning of each question. You should assume that, for all quoted program
More informationIII. Classes (Chap. 3)
III. Classes III-1 III. Classes (Chap. 3) As we have seen, C++ data types can be classified as: Fundamental (or simple or scalar): A data object of one of these types is a single object. int, double, char,
More informationC++ Review. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University
C++ Review CptS 223 Advanced Data Structures Larry Holder School of Electrical Engineering and Computer Science Washington State University 1 Purpose of Review Review some basic C++ Familiarize us with
More informationPurpose of Review. Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures
C++ Review 1 Purpose of Review Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures 2 Class The Class defines the data structure
More informationVectors of Pointers to Objects. Vectors of Objects. Vectors of unique ptrs C++11. Arrays of Objects
Vectors of Objects As we have mentioned earlier, you should almost always use vectors instead of arrays. If you need to keep track of persons (objects of class Person), you must decide what to store in
More informationOperator Overloading in C++ Systems Programming
Operator Overloading in C++ Systems Programming Operator Overloading Fundamentals of Operator Overloading Restrictions on Operator Overloading Operator Functions as Class Members vs. Global Functions Overloading
More informationStructuur van Computerprogramma s 2
Structuur van Computerprogramma s 2 dr. Dirk Deridder Dirk.Deridder@vub.ac.be http://soft.vub.ac.be/ Vrije Universiteit Brussel - Faculty of Science and Bio-Engineering Sciences - Computer Science Department
More informationOverloading & Polymorphism
Overloading & Polymorphism Overloading is considered ad-hoc polymorphism. 1 Can define new meanings (functions) of operators for specific types. Compiler recognizes which implementation to use by signature
More informationChapter 18 - C++ Operator Overloading
Chapter 18 - C++ Operator Overloading Outline 18.1 Introduction 18.2 Fundamentals of Operator Overloading 18.3 Restrictions on Operator Overloading 18.4 Operator Functions as Class Members vs. as friend
More informationChapter 15 - C++ As A "Better C"
Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference
More informationDo not write in this area TOTAL. Maximum possible points: 75
Name: Student ID: Instructor: Borja Sotomayor Do not write in this area 1 2 3 4 5 6 7 TOTAL Maximum possible points: 75 This homework assignment is divided into two parts: one related to the fundamental
More informationUniversity of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination
University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms Instructor: Douglas Wilhelm Harder Time: 2.5 hours Aides: none 14 pages Final Examination
More informationConcepts (this lecture) CSC 143. Classes with Dynamically Allocated Data. List of ints w/dups (cont.) Example: List of ints with dups.
CSC 143 Classes with Dynamically Allocated Data Concepts (this lecture) Constructors and destructors for dynamic data The this pointer Deep versus shallow copy Defining assignment (operator=) Copy constructor
More informationLECTURE 03 LINKED LIST
DATA STRUCTURES AND ALGORITHMS LECTURE 03 LINKED LIST IMRAN IHSAN ASSISTANT PROFESSOR AIR UNIVERSITY, ISLAMABAD LINKED LISTS DEFINITION A linked list is a data structure where each object is stored in
More informationInheritance and Polymorphism
Inheritance and Polymorphism 1 Inheritance extending a clock to an alarm clock deriving a class 2 Polymorphism virtual functions and polymorphism abstract classes MCS 360 Lecture 8 Introduction to Data
More informationChapter 17: Linked Lists
Chapter 17: Linked Lists Copyright 2009 Pearson Education, Inc. Copyright Publishing as Pearson 2009 Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 17.1 Introduction to the
More informationIntroduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.
Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and
More informationChapter 8. Operator Overloading, Friends, and References. Copyright 2010 Pearson Addison-Wesley. All rights reserved
Chapter 8 Operator Overloading, Friends, and References Copyright 2010 Pearson Addison-Wesley. All rights reserved Learning Objectives Basic Operator Overloading Unary operators As member functions Friends
More informationOverloaded Operators, Functions, and Students
, Functions, and Students Division of Mathematics and Computer Science Maryville College Outline Overloading Symbols 1 Overloading Symbols 2 3 Symbol Overloading Overloading Symbols A symbol is overloaded
More informationIntermediate Programming & Design (C++) Classes in C++
Classes in C++ A class is a data type similar to a C structure. It includes various local data (called data members) together with constructors, destructors and member functions. All of them are called
More informationOutline. User-dened types Categories. Constructors. Constructors. 4. Classes. Concrete classes. Default constructor. Default constructor
Outline EDAF50 C++ Programming 4. Classes Sven Gestegård Robertz Computer Science, LTH 2018 1 Classes the pointer this const for objects and members Copying objects friend inline 4. Classes 2/1 User-dened
More informationC C C C++ 2 ( ) C C++ 4 C C
# 7 11 13 C 4 8 11 20 C 9 11 27 C++ 1 10 12 4 C++ 2 11 12 11 C++ 3 12 12 18 C++ 4 C++ 5 13 1 8 ( ) 14 1 15 C++ 15 1 22 2 (D) ( ) C++ 3 6 Hello C++ 4 5 1. make Makefile.c (arithmetic.c) main main arithmetic
More informationLinked List using a Sentinel
Linked List using a Sentinel Linked List.h / Linked List.h Using a sentinel for search Created by Enoch Hwang on 2/1/10. Copyright 2010 La Sierra University. All rights reserved. / #include
More informationAbstract Data Types (ADTs) 1. Legal Values. Client Code for Rational ADT. ADT Design. CS 247: Software Engineering Principles
Abstract Data Types (ADTs) CS 247: Software Engineering Principles ADT Design An abstract data type (ADT) is a user-defined type that bundles together: the range of values that variables of that type can
More informationUEE1303(1070) S12: Object-Oriented Programming Constructors and Destructors
UEE1303(1070) S12: Object-Oriented Programming Constructors and Destructors What you will learn from Lab 5 In this laboratory, you will learn how to use constructor and copy constructor to create an object
More informationA Recursively-Defined Tree Class
A Recursively-Defined Tree Class Jeffrey D. Oldham 2000 Apr 05 We explain how to use the recursively defined Tree class. The implementation file and example use code are available. 1 The Tree Class Using
More informationCS 247: Software Engineering Principles. ADT Design
CS 247: Software Engineering Principles ADT Design Readings: Eckel, Vol. 1 Ch. 7 Function Overloading & Default Arguments Ch. 12 Operator Overloading U Waterloo CS247 (Spring 2017) p.1/17 Abstract Data
More informationCSE 303, Spring 2009 Final Exam Wednesday, June 10, 2009
CSE 303, Spring 2009 Final Exam Wednesday, June 10, 2009 Personal Information: Name: Student ID #: You have 110 minutes to complete this exam. You may receive a deduction if you keep working after the
More informationCrash Course into. Prof. Dr. Renato Pajarola
Crash Course into Prof. Dr. Renato Pajarola These slides may not be copied or distributed without explicit permission by all original copyright holders C Language Low-level programming language General
More informationOutline. A C++ Linked Structure Class A C++ Linked List C++ Linked Dynamic Memory Errors In-class work. 1 Chapter 11: C++ Linked Structures
Outline 1 Chapter 11: C++ Linked Structures A ListNode Class To support a Linked List container class LList, a ListNode class is used for the individual nodes. A ListNode object has two attributes: item
More informationCSC 270 Survey of Programming Languages. What is a Pointer?
CSC 270 Survey of Programming Languages C Lecture 6 Pointers and Dynamic Arrays What is a Pointer? A pointer is the address in memory of a variable. We call it a pointer because we envision the address
More informationTopics. bool and string types input/output library functions comments memory allocation templates classes
C++ Primer C++ is a major extension of c. It is similar to Java. The lectures in this course use pseudo-code (not C++). The textbook contains C++. The labs involve C++ programming. This lecture covers
More informationThe Class Construct Part 2
The Class Construct Part 2 Lecture 24 Sections 7.7-7.9 Robb T. Koether Hampden-Sydney College Mon, Oct 29, 2018 Robb T. Koether (Hampden-Sydney College) The Class Construct Part 2 Mon, Oct 29, 2018 1 /
More informationPractice Problems CS2620 Advanced Programming, Spring 2003
Practice Problems CS2620 Advanced Programming, Spring 2003 April 9, 2003 1. Explain the results of each vector definition: string pals[] = "pooh", "tigger", "piglet", "eeyore", "kanga" a) vector
More informationClasses internes, Classes locales, Classes anonymes
Classes internes, Classes locales, Classes anonymes Victor Marsault Aldric Degorre CPOO 2015 Enum (1) 2 Quand les utiliser: disjonctions de cas type au sens courant (eg. type de messages d erreur, type
More informationLecture 7. Log into Linux New documents posted to course webpage
Lecture 7 Log into Linux New documents posted to course webpage Coding style guideline; part of project grade is following this Homework 4, due on Monday; this is a written assignment Project 1, due next
More informationAlgorithmes certifiants
Michel Habib, LIAFA, Paris Diderot Algorithmique avancée M1 8 février 2010 Schedule of the talk 1 Programme du cours 2010-2011 2 3 Minimum spanning trees and shortest paths Consequences 4 Plan du cours
More informationCOSC 320 Exam 2 Key Spring Part 1: Hash Functions
COSC 320 Exam 2 Key Spring 2011 Part 1: Hash s 1. (5 Points) Create the templated function object lessthan, you may assume that the templated data type T has overloaded the < operator. template
More informationC++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay
C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming
More informationUEE1303(1070) S12: Object-Oriented Programming Constant Pointer and Class
UEE1303(1070) S12: Object-Oriented Programming Constant Pointer and Class What you will learn from Lab 4 In this laboratory, you will learn how to use const to identify constant pointer and the basic of
More information9. C++ advanced (II): Templates
9. C++ advanced (II): Templates 263 Motivation 264 Goal: generic vector class and functionality. Examples vector vd(10); vector vi(10); vector vi(20); auto nd = vd vd; // norm (vector
More informationTemplates and Vectors
Templates and Vectors 1 Generic Programming function templates class templates 2 the STL vector class a vector of strings enumerating elements with an iterator inserting and erasing 3 Writing our own vector
More informationHomework 5. Yuji Shimojo CMSC 330. Instructor: Prof. Reginald Y. Haseltine
Homework 5 Yuji Shimojo CMSC 330 Instructor: Prof. Reginald Y. Haseltine July 13, 2013 Question 1 Consider the following Java definition of a mutable string class. class MutableString private char[] chars
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCome and join us at WebLyceum
Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad
More informationCSE 333 Midterm Exam July 24, Name UW ID#
Name UW ID# There are 6 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,
More informationData types. CISC 1600/1610 Computer Science I. Array syntax. Memory allocation. Zero-indexing 4/4/2016. Arrays
4/4/6 CISC 6/6 Computer Science I rrays Professor Daniel Leeds dleeds@fordham.edu JMH 38 Data types Single pieces of information one integer int one symbol char one truth value bool Multiple pieces of
More informationChapter 7: Stacks. Exercises 7.2
hapter 7: Stacks Exercises 7.2 1. mytop == 0; myrray contains 3 elements: 10, 22, 37,?,? but note that only element 10 is considered to be in the stack. 2. mytop == 1; myrray contains 3 elements: 10, 9,
More informationCE221 Programming in C++ Part 1 Introduction
CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab
More informationOutline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O
Outline EDAF30 Programming in C++ 2. Introduction. More on function calls and types. Sven Gestegård Robertz Computer Science, LTH 2018 1 Function calls and parameter passing 2 Pointers, arrays, and references
More informationA <Basic> C++ Course
A C++ Course 6 Fonctions et classes templates Julien Deantoni adapted from Jean-Paul Rigault courses 1 2 Pointers and references References vs. pointers References and pointers A reference must
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More information" Templates for Functions. ! Templates for Data Abstraction. "Syntax for Class Templates. ! This swap algorithm only works for int values:
UCLA Stat 130D Statistical Computing and Visualization in C++ Templates for More Abstraction Instructor: Ivo Dinov, Asst. Prof. in Statistics / Neurology University of California, Los Angeles, Winter 2004
More informationCISC 2200 Data Structure Fall, C++ Review:3/3. 1 From last lecture:
CISC 2200 Data Structure Fall, 2016 C++ Review:3/3 1 From last lecture: pointer type and pointer variable (stores memory addresses of a variable (of any type, local or global, automatic/static/dynamic)
More informationTutorial :.Net Micro Framework et.net Gadgeteer
1 Co-développement émulateur personnalisé et application pour une cible. 1.1 Utilisation d un émulateur personnalisé Après l installation du SDK.Net Micro, dans le répertoire d exemples, Framework (ex.
More information1. #ifndef POINT_H #define POINT_H. #include <iostream> using std::ostream;
1. #ifndef POINT_H #define POINT_H class Point double x; double y; double z; Point(double xc, double yc, double zc); double getx(void) const; double gety(void) const; double getz(void) const; void setpoint(double
More informationReview. What is const member data? By what mechanism is const enforced? How do we initialize it? How do we initialize it?
Review Describe pass-by-value and pass-by-reference Why do we use pass-by-reference? What does the term calling object refer to? What is a const member function? What is a const object? How do we initialize
More informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationProgramming Abstractions
Programming Abstractions C S 1 0 6 B Cynthia Lee Topics du Jour: Make your own classes! Needed for Boggle assignment! We are starting to see a little bit in MarbleBoard assignment as well 2 Classes in
More informationDistributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes
Distributed Real-Time Control Systems Lecture 17 C++ Programming Intro to C++ Objects and Classes 1 Bibliography Classical References Covers C++ 11 2 What is C++? A computer language with object oriented
More informationCS Basics 15) Compiling a C prog.
CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 Compiling a C program Example of a small
More informationBinary Tree Implementation
Binary Tree Implementation Lecture 31 Sections 12.2-12.3 Robb T. Koether Hampden-Sydney College Mon, Apr 5, 2010 Robb T. Koether (Hampden-Sydney College) Binary Tree Implementation Mon, Apr 5, 2010 1 /
More informationCSCE 110 PROGRAMMING FUNDAMENTALS
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class Prof. amr Goneid, AUC 1 Dictionaries(1): A Key Table Class Prof. Amr Goneid, AUC 2 A Key Table
More informationBerner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2
Compiling a C program CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Example of a small program Makefile Define Variables Compilation options Conclusion Berner Fachhochschule Haute
More informationBefore we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172. In compensation, no class on Friday, Jan. 31.
Before we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172 The lab will be on pointers In compensation, no class on Friday, Jan. 31. 1 Consider the bubble function one more
More informationIntroduction to Algorithms and Data Structures. Lecture 6 - Stringing Along - Character and String Manipulation
Introduction to Algorithms and Data Structures Lecture 6 - Stringing Along - Character and String Manipulation What are Strings? Character data is stored as a numeric code that represents that particular
More informationOverloading Operators in C++
Overloading Operators in C++ C++ allows the programmer to redefine the function of most built-in operators on a class-by-class basis the operator keyword is used to declare a function that specifies what
More informationAssignment 4: SkipList
Assignment 4: SkipList Goals : Working with dynamic arrays, pointers, doubly linked lists For this assignment, you will write a Skip List data structure to store integers. When searching a Skip List, items
More informationReference Parameters A reference parameter is an alias for its corresponding argument in the function call. Use the ampersand (&) to indicate that
Reference Parameters There are two ways to pass arguments to functions: pass-by-value and pass-by-reference. pass-by-value A copy of the argument s value is made and passed to the called function. Changes
More information9. C++ advanced (II): Templates
Motivation Goal: generic vector class and functionality. Examples 9. C++ advanced (II): Templates vector vd(10); vector vi(10); vector vi(20); auto nd = vd vd; // norm (vector of double)
More informationFrom Pseudcode Algorithms directly to C++ programs
From Pseudcode Algorithms directly to C++ programs (Chapter 7) Part 1: Mapping Pseudo-code style to C++ style input, output, simple computation, lists, while loops, if statements a bit of grammar Part
More informationClasses in C++98 and C++11
Classes in C++98 and C++11 January 10, 2018 Brian A. Malloy Slide 1 of 38 1. When we refer to C++98, we are referring to C++98 and C++03, since they differ only slightly. C++98 contained 3 types of constructors,
More informationReliable C++ development - session 1: From C to C++ (and some C++ features)
Reliable C++ development - session 1: From C to C++ (and some C++ features) Thibault CHOLEZ - thibault.cholez@loria.fr TELECOM Nancy - Université de Lorraine LORIA - INRIA Nancy Grand-Est From Nicolas
More informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationCS242 COMPUTER PROGRAMMING
CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing
More information