CS 201(Introduction To Programming)

Slides:



Advertisements
Similar presentations
Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Advertisements

Complete Structure class Date {class Date { private :private : // private data and functions// private data and functions public :public : // public data.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Introduction to Programming Lecture 39. Copy Constructor.
C++ Classes & Data Abstraction
OOP Using Classes - I. Structures vs. Classes C-style structures –No “interface” If implementation changes, all programs using that struct must change.
True or false A variable of type char can hold the value 301. ( F )
Chapter Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training.
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
1 Classes and Objects. 2 Outlines Class Definitions and Objects Member Functions Data Members –Get and Set functions –Constructors.
More C++ Bryce Boe 2013/07/18 CS24, Summer 2013 C.
PART I CHAPTER 16 CS116 SENEM KUMOVA METİN 1. Structures Structures : Aggregate data types built using elements of other types struct Time { int hour;
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Introduction To Classes Chapter Procedural And Object Oriented Programming Procedural programming focuses on the process/actions that occur in a.
Learners Support Publications Classes and Objects.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 25P. 1Winter Quarter C++: I/O and Classes Lecture 25.
Chapter 10 Introduction to Classes
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Classes Definition A class is a data type whose variables are objects Object – a variable that has member functions as well the ability to hold.
11 Introduction to Object Oriented Programming (Continued) Cats.
Chapter 4 Introduction to Classes, Objects, Methods and strings
1 CSC241: Object Oriented Programming Lecture No 02.
2 Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.
Chapter 11 Friends and Overloaded Operators. Introduction to function equal // Date.h #ifndef _DATE_H_ #define _DATE_H_ class CDate { public: CDate();
C++ Class. © 2005 Pearson Addison-Wesley. All rights reserved 3-2 Abstract Data Types Figure 3.1 Isolated tasks: the implementation of task T does not.
1 Lecture 17 Operator Overloading. 2 Introduction A number of predefined operators can be applied to the built- in standard types. These operators can.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 07 classes 1 BY ADEEL ANJUM ( MSc - cs, CCNA, WEB DEVELOPER )
Introduction to Programming Lecture 40. Class Class is a user defined data type.
1 Mr. Muhammad Hanif Lecturer Information Technology MBBS Campus Dadu University of SIndh.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Object Oriented Programming(Objects& Class) Classes are an expanded concept of data structures: like.
STRUCTURES. INTRODUCTION A structure is same as that of records. It stores related information about an entity. Structure is basically a user defined.
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 6-1 Learning Objectives  Classes  Constructors  Principles of OOP  Class type member.
Starting Out with C++, 3 rd Edition 1 Chapter 13 – Introduction to Classes Procedural and Object-Oriented Programming Procedural programming is a method.
Class & Objects C++ offers another user-defined data type known class which is the most important feature of the object-oriented programming. A class can.
Constructors And Destructors. 2 Constructor Special Member Function used for Initialization -- Same Name as the Class Name Special Member Function used.
Computer Programming II Lecture 4. Functions - In C++ we use modules to divide the program into smaller and manageable code. These modules are called.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
Constructors & Destructors Controlling initialization & destruction.
Lecture 3 (UNIT -1) SUNIL KUMAR CIT-UPES.
Object-Oriented Programming (OOP) Lecture No. 15
Class and Objects UNIT II.
Chapter 16: Classes and Data Abstraction
Chapter 9 Type Conversions
Introduction to C Language
CS410 – Software Engineering Lecture #11: C++ Basics IV
Structs versus Classes
Chapter 5 Classes.
This technique is Called “Divide and Conquer”.
CMPE Data Structures and Algorithms in C++ February 22 Class Meeting
Lecture Constructors and Destructors
Chapter 3 Introduction to Classes, Objects Methods and Strings
Learning Objectives Classes Constructors Principles of OOP
CONSTRUCTORS AND DESRUCTORS
Classes and Objects.
How Dynamic Memory Works with Memory Diagram
How Classes Work with Memory Diagram
Introduction to Programming
Introduction of Programming
Lecture 16 Oct 30, 02.
CS148 Introduction to Programming II
CS410 – Software Engineering Lecture #5: C++ Basics III
Types of Computer Languages
Separating Interface from Implementation
How Dynamic Memory Works with Memory Diagram
CS148 Introduction to Programming II
How Classes Work with Memory Diagram
Objects as Function Arguments
Presentation transcript:

CS 201(Introduction To Programming) TAMOOR SAFDER BC150201755

(Class and Objects) Class Let’s have a look on the structure of a class. It is very similar to the struct keyword. Keyword class is used and the braces enclose the definition of the class i.e. class name_of_class { // definition of class } Object We have to use the name of the object, a dot operator and the data member of structure to be accessed. The data members are of normal data types like int, float, char etc. Other data types can also be used. Let’s consider an example of Date Class shown in the following statement. class Date int Day; int month; int year; };

constructor // constructor of class Date(); { Date(int,int); Date(int,int,int); } Destructor // defining the constructor // default constructor. setting the date to a default date Date:: Date() day = 1; month = 1; year = 1900;

Private public: void display(); // to display the date on the screen void setDay(int i); // setting the day void setMonth(int i); // setting the month void setYear(int i); // setting the year Public scopes private: { int day, month, year; };

int main() { Date date1, date2(12,12), date3(25,12,2002); // taking objects of Date class // displaying the dates on the screen date1.display(); date2.display(); date3.display(); } Following is the output of the above program. The default constructor is called The constructor with two arguments is called The constructor with three arguments is called The date is 1-1-1900 The date is 12-12-2002 The date is 25-12-2002 The object has destroyed