Matakuliah Tahun Versi : T0044/Pemrograman Berorientasi Obyek : 2005 : 1.0 Pertemuan 1 Pemrograman Berorientasi Obyek dengan C++ 1 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • menjelaskan sejarah, kemampuan & contoh PBO dengan Bahasa C++ 2 Outline Materi • Perbedaan C & C++ • Pengenalan C++ • Program C++ pertama 3 Sejarah C dan C++ 1967 – Martin Richard mengembangan Bahasa Pemrograman BCPL 1970 – Ken Thomson (Bell Lab) mengembangkan Bahasa B dari Bahasa BCPL utk meng-create Unix 1972 – Dennis Ritchie (Bell Lab) mengembangkan Bahasa C dari Bahasa B utk di implementasikan pada Komputer DEC PDP-11 C Hardware independent (Portable programs), Fleksibel (Machine Accessible Program), Universal 1989 – Standarisasi C oleh ANSI & ISO (ANSI/ISO 9899:1990) 4 Sejarah C dan C++ 1980 – Bjarne Stroustrup (Bell Lab) mengembangkan Bahasa C++ dari Bahasa C 1983 – C++ dipublikasikan oleh Bell Lab C++ C With Classes (Kemampuan Object Oriented Programming) OOP membangun software dengan cepat, tepat & ekonomis (produktif), mempermudah programmer menulis & memodifikasi program Objects Reuseable & Extenable 5 Berorientasi Object • Object adalah penyusun dasar (basic building block) dari OOP • Object diambil dari real world pada bidang aplikasinya (application domain) • Object dalam mail order system: companies, customer, order, product & departments • Object dalam library system: members, books, loans, reservation & cancellations • Object dalam O-O system dapat berupa benda (customers, products, members, book ), konsep(order, loan, reservation, cancellation ) atau organisasi (companies , departments ) • Object dalam implementasi komputer: GUI windows, files, atau linked list 6 Berorientasi Object • Real world objects mempunyai data properties / attributes. Dalam mail orders system, object customer punya nama, No_telpon, alamat utk tujuan invoicing. • Real world object juga mempunyai karakteristik function behavior. Dalam mail order system customer dapat mengubah No_telpon dan alamatnya. 7 Teknologi Object • Object Software unit packaging together data and methods to manipulate that data • Class Template or factory for creating objects • Attribute Properties/Data item defined as part of class or object • Behaviour Service / Operation / Method / Procedure / Function defined as part of a class or object as implementation 8 Teknologi Object • Message Request sent to an object to execute its method • Encapsulation Packaging data and operation into an object/class • Data hiding Making the internal details of an object invisible to other object • Inheritance Mechanism for defining a new class in terms of an existing class • Polymorphism The ability to hide different implementation behind the common interface 9 Unified Modeling Language (UML)™ – UML – Model object-oriented systems and aid design • Flexible – Extendable – Independent of many OOAD processes – One standard set of notations – 2001: Object Management Group (OMG) Released UML version 1.4 – Complex, feature-rich graphical language • Activity Diagram, Class Diagram, Collaboration Diagram, Componen diagram, Deployment diagram, Object Diagram, Package Diagram, Sequence Diagram, State Diagram, State Diagram, Use Case Diagram 10 Unified Modeling Language (UML)™ • Class Diagram – Association – Multiplicity – Generalization – Agregation – Composite 11 Operator, Variabel, Konstanta • Urutan Arithmetic Operator –(),*,/,%,+,–Y=2*5*5+3*5+7 = 10 * 5 + 3 * 5 + 7 = 50 + 3 * 5 + 7 = 50 + 15 + 7 = 65 + 7 = 72 • Relational Operator <, >, <=, >= • Equality Operator == , != 12 Operator, Variabel, Konstanta • Aturan penamaan Variable – Diawali huruf atau garis bawah, bukan angka – Case Sensitive – Bukan keyword • Deklarasi Konstanta – Macro Based Constant • #define pi 3.14 • #define kuadrat(x) (x*x) – Named Constant (Formal) • Const float pi = 3.14 13 Struktur Program C++ • • • • Preprocessor Directive Function Prototype void main() Argument & Return Function 14 Tugas 1 • Tugas 1A: Mahasiswa secara individu mengerjakan soal sejarah C++ dan dikumpulkan lewat email • Tugas 1B: Mahasiswa mengerjakan soal konversi program C ke C++ • Tugas 1C: Mahasiswa mengerjakan soal contoh sistem aplikasi program berbasis object 15
© Copyright 2026 Paperzz