1 CSE 459.22 Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Informática II Prof. Dr. Gustavo Patiño MJ
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Stéphane Ducasse6.1 Essential Concepts Why OO? What is OO? What are the benefits? What are the KEY concepts? Basis for all the lectures.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
1 Procedural Concept The main program coordinates calls to procedures and hands over appropriate data as parameters.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING
1 Review: Two Programming Paradigms Structural (Procedural) Object-Oriented PROGRAM PROGRAM FUNCTION OBJECT Operations Data OBJECT Operations Data OBJECT.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
Programming Languages
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
Introduction to Object-oriented programming and software development Lecture 1.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.
An Object-Oriented Approach to Programming Logic and Design
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Object Oriented Programming Principles Lecturer: Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Session-3.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Learners Support Publications Object Oriented Programming.
Lecture 19 CIS 208 Wednesday, April 06, Welcome to C++ Basic program style and I/O Class Creation Templates.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Salman Marvasti Sharif University of Technology Winter 2015.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
CS 106 Introduction to Computer Science I 03 / 22 / 2010 Instructor: Michael Eckmann.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Copyright 2005, The Ohio State University CSE – Introduction to C++ Name: Shirish Tatikonda Time: T 3:30 PM Room: BE 394
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
A Survey of Object-Oriented Concept Oscar Nierstrasz.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Programming paradigms
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Review: Two Programming Paradigms
Object Oriented Concepts -I
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
C++.
Procedural Programming
Advanced Programming Behnam Hatami Fall 2017.
Introduction to Classes and Objects
Principles of object – oriented programming UNIT-1 Chapter-1.
CPS120: Introduction to Computer Science
Introduction to Classes and Objects
CPS120: Introduction to Computer Science
C++ Object Oriented 1.
Presentation transcript:

1 CSE Programming in C++

2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire

3 Introduction to C++ Programming Concept Basic C++ C++ Extension from C

4 Focus Focus on –Programming Concepts –Programming Design Techniques Don’t get lost in –Language Technical Details

5 What is programming? Programming is taking A problem Find the area of a rectangle A set of data length width A set of functions area = length * width Then, Applying functions to data to solve the problem

6 Programming Concept Evolution Unstructured Procedural Object-Oriented

7 Procedural Concept The main program coordinates calls to procedures and hands over appropriate data as parameters.

8 Procedural Concept (II) Procedural Languages –C, Pascal, Basic, Fortran –Facilities to Pass arguments to functions Return values from functions For the rectangle problem, we develop a function int compute_area (int l, int w){ return ( l * w ); }

9 Object-Oriented Concept Objects of the program interact by sending messages to each other

10 Objects An object is an encapsulation of both functions and data Objects are an Abstraction –represent real world entities –Classes are data types that define shared common properties or attributes –Objects are instances of a class Objects have State –have a value at a particular time Objects have Operations –associated set of operations called methods that describe how to carry out operations Objects have Messages –request an object to carry out one of its operations by sending it a message –messages are the means by which we exchange data between objects

11 OO Perspective Let's look at the Rectangle through object oriented eyes: Define a new type Rectangle (a class) –Data width, length –Function area() Create an instance of the class (an object) Request the object for its area In C++, rather than writing a procedure, we define a class that encapsulates the knowledge necessary to answer the question - here, what is the area of the rectangle.

12 class Rectangle { private: int width, length; public: Rectangle(int w, int l) { width = w; length = l; } main() { Rectangle rect(3, 5); cout << rect.area()<<endl; } int area() { return width*length; } }; Example Object Oriented Code

13 Object-Oriented Programming Languages Characteristics of OOPL: –Encapsulation –Inheritance –Polymorphism OOPLs support : –Modular Programming –Ease of Development –Maintainability

14 Characteristics of OOPL Encapsulation: C ombining data structure with actions –Data structure: represents the properties, the state, or characteristics of objects –Actions: permissible behaviors that are controlled through the member functions Data hiding: Process of making certain data inaccessible Inheritance: A bility to derive new objects from old ones –permits objects of a more specific class to inherit the properties (data) and behaviors (functions) of a more general/base class –ability to define a hierarchical relationship between objects Polymorphism: A bility for different objects to interpret functions differently

15 Basic C++ Inherit all ANSI C directives Inherit all C functions You don’t have to write OOP programming in C++

16 Basic C++ Extension from C comments /* You can still use the old comment style, */ /* but you must be // very careful about mixing them */ // It's best to use this style for 1 line or partial lines /* And use this style when your comment consists of multiple lines */ cin and cout (and #include ) cout << "hey"; char name[10]; cin >> name; cout << "Hey " << name << ", nice name." << endl; cout << endl; // print a blank line declaring variables almost anywhere // declare a variable when you need it for (int k = 1; k < 5; k++){ cout << k; }

17 Basic C++ Extension from C (II) const –In C, #define statement Preprocessor - No type checking. #define n 5 –In C++, the const specifier Compiler - Type checking is applied const int n = 5; // declare and initialize New data type –Reference data type “&”. int ix; /* ix is "real" variable */ int & rx = ix; /* rx is “alias” for ix. Must initialize*/ ix = 1; /* also rx == 1 */ rx = 2; /* also ix == 2 */

18 C++ - Advance Extension C++ allows function overloading –In C++, functions can use the same names, within the same scope, if each can be distinguished by its name and signature –The signature specifies the number, type, and order of the parameters expressed as a comma separated list of argument types

19 C++ Is a better C Expressive Supports Data Abstraction Supports OOP Supports Generic Programming –Containers Stack of char, int, double etc –Generic Algorithms sort(), copy(), search() any container Stack/Vector/List

20 Take Home Message There are many different kinds of programming paradigms, OOP is one among them. In OOP, programmers see the execution of the program as a collection of dialoging objects. The main characteristics of OOPL include encapsulation, inheritance, and polymorphism.