lecture-6 - 1 Classes and Data Abstraction Object Oriented...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming – Introduction to C++ R.B. Lenin Winter 2006 DA-IICT 1 Classes and Data Abstraction
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming – Introduction to C++ R.B. Lenin Winter 2006 DA-IICT 2 Introduction • Object-oriented programming (OOP) Encapsulates data (attributes) and functions (behavior) into packages called classes – Data and functions closely related • Information hiding – Implementation details are hidden within the classes themselves • Unit of C++ programming: the class – A class is like a blueprint –reusable – Objects are instantiated (created) from the class – For example, a house is an instance of a “blueprint class” – C programmers concentrate on functions
Background image of page 2
Object Oriented Programming – Introduction to C++ R.B. Lenin Winter 2006 DA-IICT 3 1 class Time { 2 public: 3 Time(); 4 void setTime( int, int, int ); 5 void printMilitary(); 6 void printStandard(); 7 private: 8 int hour; // 0 - 23 9 int minute; // 0 - 59 10 int second; // 0 - 59 11 }; Implementing a Time Abstract Data Type with a Class • Classes – Model objects that have attributes (data members) and behaviors (member functions) – Defined using keyword class Public: and Private: are member-access specifiers. setTime , printMilitary , and printStandard are member functions. Time is the constructor. hour , minute , and second are data members.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming – Introduction to C++ R.B. Lenin Winter 2006 DA-IICT 4 Implementing a Time Abstract Data Type with a Class (II) •F o r m a t – Body delineated with braces ( { and } ) – Class definition terminates with a semicolon • Member functions and data Public - accessible wherever the program has access to an object of
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2010 for the course CSE IT325 taught by Professor Maniklaldas during the Spring '09 term at Punjab Engineering College.

Page1 / 22

lecture-6 - 1 Classes and Data Abstraction Object Oriented...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online