Object-oriented Programming and Introduction to C++
|
|
- Merilyn Jennings
- 6 years ago
- Views:
Transcription
1 Object-oriented Programming and Introduction to C Department of Computer Science Poznan University of Technology / OOP Laboratory
2 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
3 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
4 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
5 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
6 (1) abstraction encapsulation inheritance messaging modularity polymorphism
7 (2) abstraction ability to represent entity as near to the reality as it is only possible encapsulation inheritance messaging modularity polymorphism
8 (3) abstraction encapsulation inheritance messaging modularity polymorphism
9 (4) abstraction encapsulation concealment of the explicit access to the object state inheritance messaging modularity polymorphism
10 (5) abstraction encapsulation inheritance messaging modularity polymorphism
11 (6) abstraction encapsulation inheritance extensibility of the functionality of implemented classes messaging modularity polymorphism
12 (7) abstraction encapsulation inheritance messaging modularity polymorphism
13 (8) abstraction encapsulation inheritance messaging communication with objects can be reduced to signals, objects should be able to manage themselves modularity polymorphism
14 (9) abstraction encapsulation inheritance messaging modularity polymorphism
15 (10) abstraction encapsulation inheritance messaging modularity adding new functionality should require minimum changes in the code polymorphism
16 (11) abstraction encapsulation inheritance messaging modularity polymorphism
17 (12) abstraction encapsulation inheritance messaging modularity polymorphism extension of inheritance paradigm that provides dynamic binding object type recognition at a runtime
18 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
19 Paradigm differences (1) Procedural Programming Object-Oriented Programming Focus Algorithm Data Basic data Structure (structure instance) Class (object) unit Routine Function (procedure) Method (message) Routine target To perform (sub)task To change/view object state Routine area Logically consistent inseparable The minimum set of part of an algo- instruction needed to rithm change object state. (code clearness)
20 Paradigm differences (2) Data access pattern Data modification Dynamic Not possible type recognition Procedural Programming Object-Oriented Programming Everything except local Object provide a minimum possible access variables is public using interface methods called getters/setters. (messaging, encapsula- Data can be changed from any (aware of the structure!) code part tion) Self-management of an object the outside world should not be directly able to change object fields. (encapsulation) Supported (at least minimally like C++ s RTTI)
21 Paradigm differences (3) Procedural Programming Object-Oriented Programming Data initialization Dedicated functions Constructor / destructor / fi- nalization Memory Memory fully managed by Garbage collector (not management programmer necessary) Exceptions Function results Embedded mechanism Operators For types declared in language The operators can - one cannot rede- be used as functions fine operator for his structure (operator overloading)
22 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
23 favors code clearness and systematization is a natural extension of more human-friendly languages like UML thus allows developers to better use of domain knowledge makes it easer to distribute tasks over programmers holds mechanisms supporting code development (e.g. inheritance, modularity)...
24 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
25 Hello world program in C++ hello.cpp #include <iostream> using namespace std; int main() { cout << "Hello world" << endl; return 0; } Compilation and running (from the command line) > g++ hello.cpp -o hello >./hello
26 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
27 Header files Object-oriented programming basics poem.h Prosze Panstwa oto Mis. Mis jest bardzo grzeczny dzis. Chetnie Panstwu lapke poda. Nie chce podac? A to szkoda... poem.cpp #include "poem.h" by Jan Brzechwa and filtering results > g++ -E poem.cpp egrep -v "^#"
28 Multiple usage of the same header file poem2.cpp #include "poem.h" #include "poem.h" by Jan Brzechwa and filtering results > g++ -E poem2.cpp egrep -v "^#"
29 Preventing from multiple file inclusion poem3.h #ifndef POEM3_H #define POEM3_H Prosze Panstwa oto Mis. Mis jest bardzo grzeczny dzis. Chetnie Panstwu lapke poda. Nie chce podac? A to szkoda... #endif poem3.cpp #include "poem3.h" #include "poem3.h" by Jan Brzechwa and filtering results > g++ -E poem3.cpp egrep -v "^#"
30 Constants Object-oriented programming basics poem4.cpp #define Mis Niedzwiedz #include "poem3.h" #include "poem3.h" by anonymous group and filtering results > g++ -E poem4.cpp egrep -v "^#"
31 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
32 Creating object files and linking car.h #ifndef CAR_H #define CAR_H namespace cars { class Car { public: virtual void startengine(); }; } #endif car.cpp #include <iostream> #include "car.h" using namespace cars; using namespace std; void Car::startEngine() { cout << "BRRRRRMM" << endl; } main.cpp #include "car.h" using namespace cars; int main() { Car car; car.startengine(); return 0; } creating object files, linking and running > g++ -c car.cpp -o car.o > g++ -c main.cpp -o main.o > g++ *.o -o cars >./cars
33 Outline Object-oriented programming basics 1 Object-oriented programming basics 2 3
34 Dependencies between files (1) hyundai.h #ifndef HYUNDAI_H #define HYUNDAI_H #include "car.h" namespace cars { class Hyundai: public Car { public: virtual void startengine(); }; } #endif hyundai.cpp #include <iostream> #include "hyundai.h" using namespace cars; using namespace std; void Hyundai::startEngine() { Car::startEngine(); cout << "BRM" << endl; } volkswagen.h #ifndef VOLKSWAGEN_H #define VOLKSWAGEN_H #include "car.h" namespace cars { class Volkswagen: public Car { public: virtual void startengine(); }; } #endif volkswagen.cpp #include <iostream> #include "volkswagen.h" using namespace cars; using namespace std; void Volkswagen::startEngine() { Car::startEngine(); cout << "BRM BRM BRM" << endl; }
35 Dependencies between files (2) main2.cpp #include "hyundai.h" #include "volkswagen.h" using namespace cars; int main() { Car *car; car = new Volkswagen(); car->startengine(); delete car; car = new Hyundai(); car->startengine(); return 0; }
36 Dependencies between files (3) volkswagen.h car.h hyundai.h volkswagen.cpp car.cpp hyundai.cpp main2.cpp volkswagen.o car.o hyundai.o main2.o cars
37 Dependencies between files (4) volkswagen.h car.h hyundai.h volkswagen.cpp car.cpp hyundai.cpp main2.cpp volkswagen.o car.o hyundai.o main2.o cars
38 Dependencies between files (5) volkswagen.h car.h hyundai.h volkswagen.cpp car.cpp hyundai.cpp main2.cpp volkswagen.o car.o hyundai.o main2.o cars
39 Dependencies between files (6) volkswagen.h car.h hyundai.h volkswagen.cpp car.cpp hyundai.cpp main2.cpp volkswagen.o car.o hyundai.o main2.o cars
40 Dependencies between files (7) volkswagen.h car.h hyundai.h volkswagen.cpp car.cpp hyundai.cpp main2.cpp volkswagen.o car.o hyundai.o main2.o cars
41 Makefile Object-oriented programming basics Makefile all: cars cars: main2.o car.o volkswagen.o hyundai.o g++ main2.o car.o volkswagen.o hyundai.o -o cars main2.o: main2.cpp car.h volkswagen.h hyundai.h g++ -c main2.cpp -o main2.o car.o: car.cpp car.h g++ -c car.cpp -o car.o volkswagen.o: volkswagen.cpp volkswagen.h car.h g++ -c volkswagen.cpp -o volkswagen.o hyundai.o: hyundai.cpp hyundai.h car.h g++ -c hyundai.cpp -o hyundai.o clean: rm *.o rm cars running make command > make
42 Task Object-oriented programming basics Using -MM option of g++ compiler create bash script that will create Makefile that will take into account dependencies of files from directory (subdirectories should also be considered) where he is placed. Call him configure. NOTE! If in directory contains more than one file with main function configure should prompt in order to determine which one it should process.
43 Projects Games checkers chess go gomoku domino literaki (with AI) Utility programs spreadsheet (console) text editor (console)
44 Project specification Specification Each program should provide full history (containing moves in case of games and changes in case of utility programs). Programs should be intuitive and easy to use. Games should be able to identify the final state (e.g. check-mat in chess). Games should allow only permitted moves. On the other hand should allow every possible permitted moves. Each move should result in consequences prescribed by game rules (e.g. when we surround the opponent s pawn in go they should be taken as prisoners). Utility application should be as useful as possible (e.g. spreadsheet should allow to count a number of functions sum, mean value, variance and standard deviation, but also should allow to use standard operators like (-, +, *, /) and allows to pass addresses of the cells (relative and absolute). Both spreadsheet and text editor should allow to copy/cut and paste and saving to file (reading from saved file as well). None of the application requires usage of graphical library(!). You use it at your own risk this won t result in higher grade. Project will be done in group of pairs. Each pair should select project application till next week. Each application should be chosen only once for the laboratory group. Declarations of chosen application should be sent by (add [PO] including brackets to mail subject, group members name, hour and the day of your PO classes, and chosen application in body). First declaration wins. Project deadline passes Please send me your project till to 3 o clock. Every week of delay = Any doubts should be solved be (add [PO] to mail subject unless you want it to be treated as SPAM).
Java Basic Syntax. Java vs C++ Wojciech Frohmberg / OOP Laboratory. Poznan University of Technology
Java vs C++ 1 1 Department of Computer Science Poznan University of Technology 2012.10.07 / OOP Laboratory Outline 1 2 3 Outline 1 2 3 Outline 1 2 3 Tabular comparizon C++ Java Paradigm Procedural/Object-oriented
More informationCS2141 Software Development using C/C++ Compiling a C++ Program
CS2141 Software Development using C/C++ Compiling a C++ Program g++ g++ is the GNU C++ compiler. A program in a file called hello.cpp: #include using namespace std; int main( ) { cout
More informationANSI C. Data Analysis in Geophysics Demián D. Gómez November 2013
ANSI C Data Analysis in Geophysics Demián D. Gómez November 2013 ANSI C Standards published by the American National Standards Institute (1983-1989). Initially developed by Dennis Ritchie between 1969
More informationLab 1: First Steps in C++ - Eclipse
Lab 1: First Steps in C++ - Eclipse Step Zero: Select workspace 1. Upon launching eclipse, we are ask to chose a workspace: 2. We select a new workspace directory (e.g., C:\Courses ): 3. We accept the
More informationProgramming in C/C Lecture 3
Programming in C/C++ 2005- Lecture 3 http://few.vu.nl/~nsilvis/c++/ Natalia Silvis-Cividjian e-mail: nsilvis@few.vu.nl vrije Universiteit amsterdam Object Oriented Programming in C++ about object oriented
More informationCS6301 PROGRAMMING AND DATA STRUCTURES II QUESTION BANK UNIT-I 2-marks ) Give some characteristics of procedure-oriented language. Emphasis is on doing things (algorithms). Larger programs are divided
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 informationAN OVERVIEW OF C++ 1
AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function
More informationModern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi
Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance
More informationDr. Md. Humayun Kabir CSE Department, BUET
C++ Dr. Md. Humayun Kabir CSE Department, BUET History of C++ Invented by Bjarne Stroustrup at Bell Lab in 1979 Initially known as C with Classes Classes and Basic Inheritance The name was changed to C++
More informationSRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR
SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name
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 informationPolymorphism Part 1 1
Polymorphism Part 1 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid
More informationEL2310 Scientific Programming
(pronobis@kth.se) Overview Overview Wrap Up Introduction to Object Oriented Paradigm More on and Members Operator Overloading Last time Intro to C++ Differences between C and C++ Intro to OOP Today Object
More informationGovernment Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING
Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++
More informationYour First C++ Program. September 1, 2010
Your First C++ Program September 1, 2010 Your First C++ Program //*********************************************************** // File name: hello.cpp // Author: Bob Smith // Date: 09/01/2010 // Purpose:
More information3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.
3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.
More informationPaytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value
Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object
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 informationStructure of a CRC card: Tips:
CRC Cards CRC CRC = Class, Responsibilities, Collaborations Structure of a CRC card: on a small card, record: 1. at the top: the name of the class 2. on the left-hand side: the responsibilities of the
More informationSeparate Compilation of Multi-File Programs
1 About Compiling What most people mean by the phrase "compiling a program" is actually two separate steps in the creation of that program. The rst step is proper compilation. Compilation is the translation
More informationCompiling with Multiple Files The Importance of Debugging CS 16: Solving Problems with Computers I Lecture #7
Compiling with Multiple Files The Importance of Debugging CS 16: Solving Problems with Computers I Lecture #7 Ziad Matni Dept. of Computer Science, UCSB Programming in Multiple Files The Magic of Makefiles!
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 informationPartha Sarathi Mandal
MA 253: Data Structures Lab with OOP Tutorial 1 http://www.iitg.ernet.in/psm/indexing_ma253/y13/index.html Partha Sarathi Mandal psm@iitg.ernet.in Dept. of Mathematics, IIT Guwahati Reference Books Cormen,
More informationCOMP322 - Introduction to C++ Lecture 01 - Introduction
COMP322 - Introduction to C++ Lecture 01 - Introduction Robert D. Vincent School of Computer Science 6 January 2010 What this course is Crash course in C++ Only 14 lectures Single-credit course What this
More informationC++ Programming for Non-C Programmers. Supplement
C++ Programming for Non-C Programmers Supplement ii C++ Programming for Non-C Programmers C++ Programming for Non-C Programmers Published by itcourseware, 10333 E. Dry Creek Rd., Suite 150, Englewood,
More informationLOADING LIBRARY FILES IN C++
LOADING LIBRARY FILES IN C++ This article demonstrates how to load shared or dynamic library files in programs written in C++, which is not as straightforward as in C. Device drivers and library files
More informationWhy C++? C vs. C Design goals of C++ C vs. C++ - 2
Why C++? C vs. C++ - 1 Popular and relevant (used in nearly every application domain): end-user applications (Word, Excel, PowerPoint, Photoshop, Acrobat, Quicken, games) operating systems (Windows 9x,
More informationData Structures using OOP C++ Lecture 3
References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.
More informationPracticum 5 Maps and Closures
Practicum 5 Maps and Closures Assignment Details Assigned: February 18 th 2014. Due: February 20 th, 2014 at midnight. Background One of the requirements of PA1 Part 2 using a data structure to hold function
More informationCS 376b Computer Vision
CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves
More informationCS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30
CS31 Discussion 1E Jie(Jay) Wang Week1 Sept. 30 About me Jie Wang E-mail: holawj@gmail.com Office hour: Wednesday 3:30 5:30 BH2432 Thursday 12:30 1:30 BH2432 Slides of discussion will be uploaded to the
More informationPolymorphism. Zimmer CSCI 330
Polymorphism Polymorphism - is the property of OOP that allows the run-time binding of a function's name to the code that implements the function. (Run-time binding to the starting address of the code.)
More informationUnit 1 : Principles of object oriented programming
Unit 1 : Principles of object oriented programming Difference Between Procedure Oriented Programming (POP) & Object Oriented Programming (OOP) Divided Into Importance Procedure Oriented Programming In
More informationOutline 2017/03/17. (sections from
Outline 2017/03/17 clarifications I/O basic namespaces and structures (recall) Object Oriented programming (8.1) Classes (8.2 8.6) public, protected and private Constructors and destructors Getters and
More informationImplementing an ADT with a Class
Implementing an ADT with a Class the header file contains the class definition the source code file normally contains the class s method definitions when using Visual C++ 2012, the source code and the
More informationUnified Modeling Language a case study
Unified Modeling Language a case study 1 an online phone book use case diagram encapsulating a file 2 Command Line Arguments arguments of main arrays of strings 3 Class Definition the filesphonebook.h
More informationIntroducing C++ to Java Programmers
Introducing C++ to Java Programmers by Kip Irvine updated 2/27/2003 1 Philosophy of C++ Bjarne Stroustrup invented C++ in the early 1980's at Bell Laboratories First called "C with classes" Design Goals:
More informationUEE1303(1070) S 12 Object-Oriented Programming in C++
Computational Intelligence on Automation Lab @ NCTU UEE1303(1070) S 12 Object-Oriented Programming in C++ Lecture 01: C/C++ Overview and OOP by Example Learning Objectives You should be able to review/understand:
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 informationCPSC 427: Object-Oriented Programming
CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 3 September 7, 2016 CPSC 427, Lecture 3 1/27 Insertion Sort Example Program specification Monolithic solution Modular solution in C Modular
More informationSTUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationChapter 1: Object-Oriented Programming Using C++
Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms
More informationObject Orientated Analysis and Design. Benjamin Kenwright
Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary
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 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 informationDiscussion Week 1. TA: Kyle Dewey. Sunday, September 25, 11
Discussion Week 1 TA: Kyle Dewey Project 0 Walkthrough Makefiles What? A programmable command that can generate new files based on existing ones Only that which is needed is made main.c main.o a.out helpers.h
More informationC++ Lab 03 - C++ Functions
C++ Lab 03 - C++ Functions 2.680 Unmanned Marine Vehicle Autonomy, Sensing and Communications Spring 2018 Michael Benjamin, mikerb@mit.edu Department of Mechanical Engineering Computer Science and Artificial
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 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 informationClasses: A Deeper Look
Classes: A Deeper Look 1 Introduction Implementing a Time Abstract Data Type with a class Class Scope and Accessing Class Members Separating Interface from Implementation Controlling Access to Members
More informationCS11 Intro C++ Spring 2018 Lecture 1
CS11 Intro C++ Spring 2018 Lecture 1 Welcome to CS11 Intro C++! An introduction to the C++ programming language and tools Prerequisites: CS11 C track, or equivalent experience with a curly-brace language,
More informationConstructor - example
Constructors A constructor is a special member function whose task is to initialize the objects of its class. It is special because its name is same as the class name. The constructor is invoked whenever
More informationCS32 Midterm Exam E01, F15, Phill Conrad, UC Santa Barbara Wednesday, 10/28/2015, 11am 12:15pm
1 CS32 Midterm Exam E01, F15, Phill Conrad, UC Santa Barbara Wednesday, 10/28/2015, 11am 12:15pm Please write your name above AND AT THE TOP OF EVERY PAGE Be sure you turn in every page of this exam. "End
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 informationCS 251 INTERMEDIATE SOFTWARE DESIGN SPRING C ++ Basics Review part 2 Auto pointer, templates, STL algorithms
CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 C ++ Basics Review part 2 Auto pointer, templates, STL algorithms AUTO POINTER (AUTO_PTR) //Example showing a bad situation with naked pointers void MyFunction()
More information1/29/2011 AUTO POINTER (AUTO_PTR) INTERMEDIATE SOFTWARE DESIGN SPRING delete ptr might not happen memory leak!
//Example showing a bad situation with naked pointers CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 C ++ Basics Review part 2 Auto pointer, templates, STL algorithms void MyFunction() MyClass* ptr( new
More informationQt Introduction. Topics. C++ Build Process. Ch & Ch 3. 1) What's Qt? 2) How can we make a Qt console program? 3) How can we use dialogs?
Topics Qt Introduction Ch 1.5 1.11 & Ch 3 1) What's Qt? 2) How can we make a Qt console program? 3) How can we use dialogs? Q: How do you pronounce Qt? A: This puppy is... 23/01/12 CMPT 212 Slides #5 Dr.
More informationEL2310 Scientific Programming
Lecture 14: Object Oriented Programming in C++ (ramviyas@kth.se) Overview Overview Lecture 14: Object Oriented Programming in C++ Classes (cont d) More on Classes and Members Group presentations Last time
More informationEL2310 Scientific Programming
Lecture 14: Object Oriented Programming in C++ (fpokorny@kth.se) Overview Overview Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes
More informationIntroduction to Programming session 24
Introduction to Programming session 24 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2010 These slides are created using Deitel sslides Sharif Universityof Technology Outlines Introduction
More informationCIS 190: C/C++ Programming. Classes in C++
CIS 190: C/C++ Programming Classes in C++ Outline Header Protection Functions in C++ Procedural Programming vs OOP Classes Access Constructors Headers in C++ done same way as in C including user.h files:
More information엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University COPYRIGHTS 2017 EOM, HYEONSANG ALL RIGHTS RESERVED
엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University COPYRIGHTS 2017 EOM, HYEONSANG ALL RIGHTS RESERVED Outline - Questionnaire Results - Java Overview - Java Examples
More informationINTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE
HEADER FILE A header (.h,.hpp,...) file contains Class definitions ( class X {... }; ) Inline function definitions ( inline int get_x() {... } ) Function declarations ( void help(); ) Object declarations
More informationObject Oriented Design
Object Oriented Design Lecture 3: Introduction to C++ (Continue) Examples using declarations that eliminate the need to repeat the std:: prefix 1 Examples using namespace std; enables a program to use
More informationCS 247: Software Engineering Principles. Modules
CS 247: Software Engineering Principles Modules Readings: Eckel, Vol. 1 Ch. 2 Making and Using Objects: The Process of Language Translation Ch. 3 The C in C++: Make: Managing separate compilation Ch. 10
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 information4. Structure of a C++ program
4.1 Basic Structure 4. Structure of a C++ program The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which
More informationTutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays
Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Outline 13.1 Test-Driving the Salary Survey Application 13.2 Introducing Arrays 13.3 Declaring and Initializing Arrays 13.4 Constructing
More information1a Computers, Problem Solving!
1a Computers, Problem Solving!! 1E3! 1a Computers and Problem Solving 1 Objectives! n To introduce the architecture of a computer.! n To introduce the notion of a programming language.! n To explore computational
More informationMidterm Exam 5 April 20, 2015
Midterm Exam 5 April 20, 2015 Name: Section 1: Multiple Choice Questions (24 pts total, 3 pts each) Q1: Which of the following is not a kind of inheritance in C++? a. public. b. private. c. static. d.
More informationProgramming, numerics and optimization
Programming, numerics and optimization Lecture A-4: Object-oriented programming Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428
More informationUse the dot operator to access a member of a specific object.
Lab 16 Class A class is a data type that can contain several parts, which are called members. There are two types of members, data member and functions. An object is an instance of a class, and each object
More informationPIC 10A Objects/Classes
PIC 10A Objects/Classes Ernest Ryu UCLA Mathematics Last edited: November 13, 2017 User-defined types In C++, we can define our own custom types. Object is synonymous to variable, and class is synonymous
More informationA SHORT COURSE ON C++
Introduction to A SHORT COURSE ON School of Mathematics Semester 1 2008 Introduction to OUTLINE 1 INTRODUCTION TO 2 FLOW CONTROL AND FUNCTIONS If Else Looping Functions Cmath Library Prototyping Introduction
More informationSystem Design and Programming II
System Design and Programming II CSCI 194 Section 01 CRN: 20220 Spring 2016 David L. Sylvester, Sr., Assistant Professor Chapter 15 Inheritance, Polymorphism, And Virtual Functions What is Inheritance?
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 informationInheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017
OOP components For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Data Abstraction Information Hiding, ADTs Encapsulation Type Extensibility Operator Overloading
More informationChapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction
Chapter 1: An Overview of Computers and Programming Languages Objectives Objectives (cont d.) In this chapter, you will: Learn about different types of computers Explore hardware and software Learn about
More informationWhat is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1
Polymorphism Part 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid adult
More informationScientific Computing
Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course
More informationObject Oriented Programming. Solved MCQs - Part 2
Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What
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 informationECE 462 Object-Oriented Programming using C++ and Java Design Issues and Multiple Inheritance in C++
ECE 462 Object-Oriented Programming using C++ and Java Design Issues and Multiple Inheritance in C++ YHL/SPM 2016 1 A class provides interface and implementation. Code reuse is good but a class, once declared,
More informationC++ basics Getting started with, and Data Types.
C++ basics Getting started with, and Data Types pm_jat@daiict.ac.in Recap Last Lecture We talked about Variables - Variables, their binding to type, storage etc., Categorization based on storage binding
More informationCIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts)
CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts) Problem 0: Install Eclipse + CDT (or, as an alternative, Netbeans). Follow the instructions on my web site.
More informationExceptions, Case Study-Exception handling in C++.
PART III: Structuring of Computations- Structuring the computation, Expressions and statements, Conditional execution and iteration, Routines, Style issues: side effects and aliasing, Exceptions, Case
More informationC++ Programming Lecture 8 Software Engineering Group
C++ Programming Lecture 8 Software Engineering Group Philipp D. Schubert VKrit This time for real (hopefully) Date: 15.12.2017 Time: 15:45 h Your opinion is important! Please use the free text comments
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 informationLaboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++
Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It
More informationThis assignment requires that you complete the following tasks (in no particular order).
Construction Objectives The objectives of this assignment are: (1) Implement your FCS design with high-quality code and thorough unit tests (2) Gain experience doing a task breakdown (3) Gain experience
More informationENERGY 211 / CME 211. Evolution
ENERGY 211 / CME 211 Lecture 2 September 24, 2008 1 Evolution In the beginning, we all used assembly That was too tedious, so a very crude compiler for FORTRAN was built FORTRAN was still too painful to
More informationCrash Course in C++ R F L Evans. www-users.york.ac.uk/~rfle500/
Crash Course in C++ R F L Evans www-users.york.ac.uk/~rfle500/ Course overview Lecture 1 - Introduction to C++ Lecture 2 - Functions and Data Lecture 3 - Namespaces and Files Lecture 4 - Code Organization
More informationPart III Synchronization A bit of C++ and ThreadMentor
Part III Synchronization A bit of C++ and ThreadMentor Spring 2018 I don t know what the programming language of the year 2000 will look like, but I know it will be called FORTRAN. 1 Charles Anthony Richard
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 informationObject-oriented Programming in C++
Object-oriented Programming in C++ Working with C and C++ Wolfgang Eckhardt, Tobias Neckel March 23, 2015 Working with C and C++, March 23, 2015 1 Challenges of This Course Heterogeneity of the audience
More informationProgram Organization and Comments
C / C++ PROGRAMMING Program Organization and Comments Copyright 2013 Dan McElroy Programming Organization The layout of a program should be fairly straight forward and simple. Although it may just look
More informationIntroduction to Object-Oriented Programming with C++
Computational Introduction to Object-Oriented ming with C++ 02/19/2009 Outline 1 2 3 4 1 Read Chapter 8 Control logic and iteration 2 s of Section 8.10: Part I, (1) - (11) Due next Tuesday, February 24
More information