Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Review :: Kisi-kisi UTS ::

Presentasi serupa

Presentasi berjudul: "Review :: Kisi-kisi UTS ::"— Transcript presentasi:

1 Review :: Kisi-kisi UTS ::
Pertemuan 5 Review :: Kisi-kisi UTS ::


3 CLASSES Is the user defined data types
A collection of objects of similar type Example: Object mango, apple, and orange is member of class fruit Object TF, TI, TK, TP is member of class Jurusan Object jip, sedan, bus, truk is member of class mobil

4 OBJECTS Is the variables of program
Have a life cycle. They can be created and destroyed. Interacts by sending message to one another Contains data and code/ function to manipulate the data

5 CLASSES & OBJECTS SPECIFYING A CLASS class class_name { private:
variable_declarations; function_declarations; public: } Keywords private and public known as visibility labels. private can be accessed only from within the class. Data member/ Variable is commonly private. public can be accessed from outside the class. Member function is commonly public.

6 Class Data/ Variabel Private Area No Entry ! Function/ Method
Public Area Data/ Variabel Function/ Method Entry Allowed

7 Konversi Prosedural ke OOP
Pastikan program sudah terbagi menjadi fungsi-fungsi/ modular. Identifikasi class yang bisa dibuat. Identifikasi data member dan member function untuk class yang bersangkutan. Tentukan bagian private dan public class (sesuaikan dengan skenario fungsi utama). Buat fungsi utamanya (void main()). Membuat obyek dari class. Menjalankan bagian public dari class.

8 //PROCEDURAL PROGRAMMING #include “stdio.h” void main()
#include “iostream.h” class balok { private : int p, l, t, volume; public : void input(void) { printf(“Masukkan P = “); scanf(“%d”, &p); printf(“Masukkan L = “); scanf(“%d”, &l); printf(“Masukkan T = “); scanf(“%d”, &t); }; void hitung(void) { volume = p * l * t; }; void output(void) { printf(“Volume = %d\n”, volume); }; void main() { balok balokku; printf(“Program Balok\n”); balokku.input(); balokku.hitung(); balokku.output(); } //PROCEDURAL PROGRAMMING #include “stdio.h” void main() { int p, l, t, volume; printf(“Program Balok\n”); printf(“Masukkan P = “); scanf(“%d”, &p); printf(“Masukkan L = “); scanf(“%d”, &l); printf(“Masukkan T = “); scanf(“%d”, &t); volume = p * l * t; printf(“Volume = %d\n”, volume); }

9 Constructors and Destructors
Parameterized Constructors Multiple Constructors Constructors with Default Arguments Copy Constructors Destructors

10 Simple Constructor & destructor
#include<iostream.h> class coba { int kode; public : coba() { cout << "Kode = "<< kode << endl; cout << "konstruktor dijalankan...\n"; kode = 1; }; ~coba() { cout << "destruktor dijalankan...\n"; cout << "Kode = "<< kode << endl; void show() void main() { coba cobaku;; }

Download ppt "Review :: Kisi-kisi UTS ::"

Presentasi serupa

Iklan oleh Google