1 / 7

Tutorial 3 More C++ and ADT

Tutorial 3 More C++ and ADT. Admin. Some students have moved to different class Changes have been reflected in the attendance list See the last few lines Compare this scenario with our question 2…

dee
Download Presentation

Tutorial 3 More C++ and ADT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tutorial 3More C++ and ADT

  2. Admin • Some students have moved to different class • Changes have been reflected in the attendance list • See the last few lines • Compare this scenario with our question 2… • If I put these students (who moved to different group) in alphabetical order, I need to shift the rest downwards • I do not want to print the attendance list again… • No more swap request will be entertained • Please try to achieve 100% attendancein your respective class

  3. Error Handling (in C++) • When a (runtime) error happens… • There are many ways to handle it… • Print error message, • Re-do the task, • Quit program, etc • Using “throw and catch”… • We will see this in action later in Q1 • “throw and catch” is also available in Java

  4. Abstract Data Type (ADT) • Abstract Data Type • Data + Operations (Algorithms) to organize that data structure • Data Structure: “Structure of Data”, structure makes life easier • Algorithm: Step by step way to solve certain problem • Walls: We do not need to know the implementation details • Examples: Complex Number, Sphere, ColoredSphere:Sphere, List, etc • Wait! Contradictions? • We are given so many implementation details here! Why bother? • In fact, we are going to do that throughout this module  • To give you a strong theoretical foundation… • Later on, you will just use these ADTs for your programming tasks • Like C++ STL

  5. C++ Standard Template Library • C++ has Standard Template Library (STL) • This library can simplify your life… • Reference: • http://www.cppreference.com • Today’s topic is STL Vector • Your friend who do Q2 will show some ideas • Throughout the semester, we will learn more

  6. Classes in C++ to Implement ADT • Basic pattern: • In “header file”  *.hclass C {} { public: // the opening in the wall… // put constructor/destructor and public methods here (accessor/mutator/etc) private: // put hidden attributes or local methods here}; • In “implementation file”  *.cpp#include “header_file_name.h”C::C() { // constructor here }C::~C() { // destructor here }C::methodname() { // implementation here }

  7. Student Presentation (Q3 longer…) • T5: • LAU WAI HOE AARON • LEONARDUS ADI PRASETYA • LI JIALONG • T10: • HU FAN • IMANTHI UDESHINI D B • JIANG YONGBO • T13: • FAN LANLAN • GAO MINMIN • HAO SHUAI • T9: • HOO CHIN HAU • KALYANI IYER • KOAY ZI HAO • T17 • CHENG LULU • CHEW JIE BIN ELROY • CHONG LEE KEE

More Related