c++day-1

Upload: eshamu

Post on 04-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 C++Day-1

    1/35

  • 7/31/2019 C++Day-1

    2/35

  • 7/31/2019 C++Day-1

    3/35

    Define Class & Objects

    Characteristics of OOPS

    History of C++

    Difference Between C & C++

    C++ Programming Structure

    Introduction to Objects

  • 7/31/2019 C++Day-1

    4/35

    All around us in the

    real world areobjects.

    Each object has

    certain

    characteristics andexhibits certain

    behaviour

  • 7/31/2019 C++Day-1

    5/35

  • 7/31/2019 C++Day-1

    6/35

    Data

    Color : Black

    Year : 2008

    Actions

    Start

    Stop

    Accelerate

    OBJECT

  • 7/31/2019 C++Day-1

    7/35

    The Object-Oriented Approach - III

    PersonnelAccounts Sales

    The real world around is full of objects .We can consider both living

    beings as well as things as objects.For example,the different

    departments in a company are objects.

  • 7/31/2019 C++Day-1

    8/35

    The drawbacks of Traditional Programming

    approach are

    Unmanageable Programs

    Code Reusability not Optimum

    Problems in Modification of Data

    Difficulty in Implementation

  • 7/31/2019 C++Day-1

    9/35

    ObjectOriented Programming

    Accounts

    Data

    Employee details

    Salary statements

    Bills

    Vouchers

    Reciepts

    Functions

    Calculate salary

    Pay salary

    Pay bills

    Tally accounts

    Transact with banks

    Here the application has to implement the entities as they are

    seen in real life and associate actions and attributes with each.

  • 7/31/2019 C++Day-1

    10/35

    Benefits of Object Oriented Programming approach

    are -

    OOP offers better implementation

    OOP offers better data security

    OOP offers better code reusability

    OOP offers more flexibility

    OOP offers better manageable programs

    Large complexity in the software developmentcan be easily managed

    User defined datatypes can be easily constructed

  • 7/31/2019 C++Day-1

    11/35

    Object Oriented Approach

    Problem

    Identification Analysis

    Design

    Development

    Testing

    Implementation

    Maintenance

  • 7/31/2019 C++Day-1

    12/35

    Data acquisition Systems

    Client/Server Computing

    Object

    Oriented Database applications

    Artificial Intelligence and expert systems

    systems such as process control, temperature control etc.

    GUI based system such as Windows Applications

    Computer Aided Design and manufacturing Systems

  • 7/31/2019 C++Day-1

    13/35

    Encapsulation

    Data Abstraction

    Inheritance

    Polymorphism

    Class

  • 7/31/2019 C++Day-1

    14/35

    Grouping of data and methods into a

    single entity is known as Data

    Encapsulation

    It is a technical name for

    information hiding. (i.e data hiding ordata security)

  • 7/31/2019 C++Day-1

    15/35

    Encapsulation

    Not accessible from

    outside class

    Accessible from outside

    class

    Private

    Public

    Class

  • 7/31/2019 C++Day-1

    16/35

    Data abstraction enhances security as use

    of data is restricted to certain functions

    only.

    Abstraction is more used where you

    want only a certain number of

    functions/methods are accessing data.

  • 7/31/2019 C++Day-1

    17/35

    Attributes

    Methods

    Class

    For Example

    Data abstraction is a process of

    identifying properties and

    methods related much to a

    particular entity as relevant to the

    application

  • 7/31/2019 C++Day-1

    18/35

    It is the process ofcreating a new class from

    an existing class

  • 7/31/2019 C++Day-1

    19/35

    Insects Mammals Reptiles Amphibians

    Humans Non-Humans

    Animals

    Reusability can be achieved through inheritance

  • 7/31/2019 C++Day-1

    20/35

    Reusability

    Programs can be

    broken into reusable

    objects

    Existing classes can be

    used with additional

    features

    Shape

  • 7/31/2019 C++Day-1

    21/35

  • 7/31/2019 C++Day-1

    22/35

    polymorphism allows a programmer topurse a course of action by sending a

    message to an object without concerningabout how the software system is toimplement the action

    Simply defined as Same thingcan behave different ones

  • 7/31/2019 C++Day-1

    23/35

    Class -

    Artiste

    Dancer PoetSculptor

    Class : Shape

    Methods :

    DrawMove

    Initialize

    Subclasses

  • 7/31/2019 C++Day-1

    24/35

    A class is what defines all the data

    members and the methods that an objectshould have

    The class defines the characteristics that

    the object will possess; it could also bereferred to as a blueprint of the object.

  • 7/31/2019 C++Day-1

    25/35

    For Example

    Polygon

    objectsPolygon class

    Properties

    VerticesBorder Color

    Fill Color

    Methods

    DrawErase

    Move

    Abstract

    into

  • 7/31/2019 C++Day-1

    26/35

    Simply defined as a structure that combines the objects with

    some attributes (data structure) and some behavior

    (operation)

    +

  • 7/31/2019 C++Day-1

    27/35

    Access Specifiers of a Class

    Class

    Data or

    functions

    Data or

    functions

    Private

    Public

    Not

    accessible

    from outsidethe class

    Accessiblefrom outside

    the class

  • 7/31/2019 C++Day-1

    28/35

    To access the member dataand member function defined

    inside the class

  • 7/31/2019 C++Day-1

    29/35

    Some of the leading object oriented languages are:

    C++

    Smalltalk Eiffel

    CLOS

    Java

    Object Oriented Languages

  • 7/31/2019 C++Day-1

    30/35

    Author of C++ is

    Bjarne stroustrup

    He invented this language in1980's at

    AT&T Bell Laboratories

    All the C programs can be run

    successfully using C++ compiler

  • 7/31/2019 C++Day-1

    31/35

    C++ was designed using twolanguages such as C Language

    which gives the low-level feature

    andSimula67 provides the

    class concept.

  • 7/31/2019 C++Day-1

    32/35

    C Language C++ Language

    Procedural Programming Language Object Oriented Programming

    Language

    Headerfile : #include #include

    \n is used to go to the next line we can use endl statement

    Function prototypes are optional All Functions must be protyped

    Local variables declared only the start

    of a C program

    It can be declared anywhere in a

    program, before they are used

    Return type for a function is optional Return type must be specified

    Do not permit data Hiding They permit data hiding

    Bydefault structure members are

    public

    class members are private

    We can call a main() function within a

    program

    This is not allowed

  • 7/31/2019 C++Day-1

    33/35

    Each class specification starts with the keyword class

    The Class Specification must always end with a semicolon (;)

    Data abstraction is the ability to create user-defined data

    types for modeling real world objects using built-in data types.

    Classes are used for data abstraction by hiding theimplementation of a type in the private part.

    Polymorphism in Greek word means ManyForms

  • 7/31/2019 C++Day-1

    34/35

    A class is an enhanced structure that provides Object-Oriented

    Features of C++An object is an instance of a class which combines both data

    and functions together.

    Encapsulation is the process of combining member functions

    and the data it manipulates and keeps them safe from outside

    interferrence

    The three access specifiers in a class are

    private,public,protectedBy default all members declared inside a class are private to

    that class

    C++ provides two pre-defined objects cin and cout for handling

    input and output

  • 7/31/2019 C++Day-1

    35/35

    EXERCISES

    1. Describe the Basic concepts of OOPS?

    2. List the various applications of Object oriented

    Programming?

    3. Explain briefly Classes & Objects?

    4. State the use of #include directive in C++?

    5. List the various benefits of Object Oriented Programming?