tailieunhanh - Lecture Object oriented programming - Lecture no 02

In this chapter you will learn about the following: Frameworks, reusable software subsystems that implement important facilities which many applications can use; the client–server architecture, an important way of designing programs in which the software is divided into two main parts: a client program which runs on each user’s computer, and a server program with which each user’s client communicates in order to obtain services; a client–server framework written in Java. | CSC241: Object Oriented Programming Lecture No 02 Previous lecture A simple analogy A class is a blue print . car engineering drawing An object has existence . my car Each object has its attributes (variables) and behavior (functions) To perform a task describe by class, an object of that class must be created Class definition begins with keyword class Class name begins with capital letter Class definition is enlosed in pair of braces { } Cont. Member function that appear after the access specifier public can be called by other function and member functions of that class Access specifier are always followed by : Each message sent to an object is a member-function call that tells the object to perform a task Member function can be access by object of class using dot operator Defining a class with member function Today’s Lecture Simple C++ program using cin and cout Member function with parameters Set functions and get functions Constructor Member function with parameter Write a . | CSC241: Object Oriented Programming Lecture No 02 Previous lecture A simple analogy A class is a blue print . car engineering drawing An object has existence . my car Each object has its attributes (variables) and behavior (functions) To perform a task describe by class, an object of that class must be created Class definition begins with keyword class Class name begins with capital letter Class definition is enlosed in pair of braces { } Cont. Member function that appear after the access specifier public can be called by other function and member functions of that class Access specifier are always followed by : Each message sent to an object is a member-function call that tells the object to perform a task Member function can be access by object of class using dot operator Defining a class with member function Today’s Lecture Simple C++ program using cin and cout Member function with parameters Set functions and get functions Constructor Member function with parameter Write a program A book class Class data The class Book contain three data items char name[15]; int pages; float price; There can be any number of data members in a class just as in structure Data member are after the keyword private, so they can be accessed from within the class, but not outside Member function These functions are included in a class There are four member functions in class Book setName(char *n) setPages(int p) setPrice(float p) display() These functions are followed by a keyword public, so they can be accessed outside the class Class data and member function Access specifier label public and private Function are public and data is private Data is hidden so that it can be safe from accidental manipulation Functions operates on data are public so they can be accessed from outside the class Defining Objects name pages price b1 Operating system 500 Cont. Defining an object is similar to defining a variable of any data type: Space is set aside for it in memory . int x; .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.