SlideShare a Scribd company logo
1 of 6
Download to read offline
Object Oriented Program 
Apa itu Object Oriented Program..? 
Object Oriented Program atau yang biasa disebut OOP adalah sebuah struktur program yang 
menganggap semua yang ada di dalamnya sebgai sebuah objek. Yang mana yang dikatakan 
objek? Dalam sebuah program OOP mempunyai beberapa sususan: 
1. Class 
Class adalah sebuah gambaran dari sebuah bagian dari program. Terlalu susah dimengerti? 
Anggap saja Class itu adalah bagian dari program untuk mengelompokkan perintah 
perintah tertentu. Ya, mengelompokkan. Jika sebuah kelas kuliah berisi mahasiswa, 
pengajar, dan sarana prasarana; maka Class berisi berbagai macam objek berupa variabel 
ataupun method (function atau fungsi) 
2. Object 
Objek merupakan implementasi atau penerapan dari Class, yang menyirikan Class, yang 
memberi karakteristik pada Class. Maksudnya objek di sini yang akan membentuk Class. 
Objek di sini berupa: 
1. Method 
Method merupakan suatu fungsi yang menampung perintah perintah tertentu. Bisa 
juga disebut sebagai Function atau Fungsi. 
2. Global Variabel 
Seperti variabel pada umunya, hanya saja sifatnya lebih luas. Dapat dipanggil di 
berbagai method atau class yang berbeda. Ciri ciri variabel global adalah letak 
pendeklarasiannya, variabel global tidak dideklarasikan di dalam sebuah method. 
Melainkan di luar method
Contoh program 
#include<iostream> 
using namespace std; 
class Universe // deklarasi class dengan nama Universe 
{ 
public: // inisiasi akses untuk perintah di bawahnya 
int continental; // hingga ditemukan inisiasi lain 
public: 
void Asia() // deklarasi method dengan nama Asia 
{ 
cout<<"ntSome Nations of Asia:"; 
cout<<"nt1. Indonesia"; 
cout<<"nt2. Saudi Arabia"; 
cout<<"nt3. China"; 
cout<<"nt4. Japan"; 
cout<<"nt5. Singapore"; 
cout<<"nn"; 
} 
void Europe() // deklarasi method dengan nama Europe 
{ 
cout<<"ntSome Nations of Europe:"; 
cout<<"nt1. Germain"; 
cout<<"nt2. England"; 
cout<<"nt3. Russia"; 
cout<<"nt4. Bosnia"; 
cout<<"nt5. Albania"; 
cout<<"nn"; 
} 
void SouthAmerica() // deklarasi method dengan nama SouthAmerica 
{ 
cout<<"ntSome Nation of South America:"; 
cout<<"nt1. Brazil"; 
cout<<"nt2. Argentina"; 
cout<<"nt3. Chile"; 
cout<<"nt4. Uruguay"; 
cout<<"nt5. Bolivia"; 
cout<<"nn"; 
} 
};
int main() 
{ 
Universe universe; // inisialisasi class Universe sebagai universe 
cout<<"nn"; 
cout<<"nt1. Asia"; 
cout<<"nt2. Europe"; 
cout<<"nt3. South America"; 
cout<<"ntInput Your Choice: "; 
cin>>universe.continental; // dalam pemanggilan objek dari suatu class, 
// harus diawali oleh inisial class pemiliknya 
if ( universe.continental == 1 ) // itu biar jelas, kita akan memanggil objek 
universe.Asia(); // dari kelas yang mana 
else if ( universe.continental == 2 ) // ingat, pemanggilan objek harus diawali 
universe.Europe(); // inisial dari class-nya 
else if ( universe.continental == 3 ) // jadi ketentuannya: inisial.objek 
universe.SouthAmerica(); // ingat, ADA TITIK SETELAH INISIAL CLASS 
else 
return 0; 
} 
keterangan: 
• public merupakan keterangan akses untuk suatu variabel atau method. Public berarti 
perintah atau variabel atau method tersebut dapat dipanggil di dalam class lain. Ada 3 
jenis access identifier, yaitu: 
◦ public 
seperti yang sudah dijelaskan di atas 
◦ protected 
hanya dapat dipanggil di class itu sendiri dan class turunannya 
◦ private 
hanya dapat dipanggil di class itu sendiri
Hasil running program:
IDE : Code::Blocks 
Compiler : gcc 
System : Linux 
Office Tool : LibreOffice Writer 
Kontak Lengkap: 
Muhammad Chairul Umam 
Email 
mirulumam@gmail.com 
mirulumam@outlook.com 
mirulumam@muslim.com 
Blog pribadi 
mirulumam

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

C++ Programming: Class

  • 1.
  • 2. Object Oriented Program Apa itu Object Oriented Program..? Object Oriented Program atau yang biasa disebut OOP adalah sebuah struktur program yang menganggap semua yang ada di dalamnya sebgai sebuah objek. Yang mana yang dikatakan objek? Dalam sebuah program OOP mempunyai beberapa sususan: 1. Class Class adalah sebuah gambaran dari sebuah bagian dari program. Terlalu susah dimengerti? Anggap saja Class itu adalah bagian dari program untuk mengelompokkan perintah perintah tertentu. Ya, mengelompokkan. Jika sebuah kelas kuliah berisi mahasiswa, pengajar, dan sarana prasarana; maka Class berisi berbagai macam objek berupa variabel ataupun method (function atau fungsi) 2. Object Objek merupakan implementasi atau penerapan dari Class, yang menyirikan Class, yang memberi karakteristik pada Class. Maksudnya objek di sini yang akan membentuk Class. Objek di sini berupa: 1. Method Method merupakan suatu fungsi yang menampung perintah perintah tertentu. Bisa juga disebut sebagai Function atau Fungsi. 2. Global Variabel Seperti variabel pada umunya, hanya saja sifatnya lebih luas. Dapat dipanggil di berbagai method atau class yang berbeda. Ciri ciri variabel global adalah letak pendeklarasiannya, variabel global tidak dideklarasikan di dalam sebuah method. Melainkan di luar method
  • 3. Contoh program #include<iostream> using namespace std; class Universe // deklarasi class dengan nama Universe { public: // inisiasi akses untuk perintah di bawahnya int continental; // hingga ditemukan inisiasi lain public: void Asia() // deklarasi method dengan nama Asia { cout<<"ntSome Nations of Asia:"; cout<<"nt1. Indonesia"; cout<<"nt2. Saudi Arabia"; cout<<"nt3. China"; cout<<"nt4. Japan"; cout<<"nt5. Singapore"; cout<<"nn"; } void Europe() // deklarasi method dengan nama Europe { cout<<"ntSome Nations of Europe:"; cout<<"nt1. Germain"; cout<<"nt2. England"; cout<<"nt3. Russia"; cout<<"nt4. Bosnia"; cout<<"nt5. Albania"; cout<<"nn"; } void SouthAmerica() // deklarasi method dengan nama SouthAmerica { cout<<"ntSome Nation of South America:"; cout<<"nt1. Brazil"; cout<<"nt2. Argentina"; cout<<"nt3. Chile"; cout<<"nt4. Uruguay"; cout<<"nt5. Bolivia"; cout<<"nn"; } };
  • 4. int main() { Universe universe; // inisialisasi class Universe sebagai universe cout<<"nn"; cout<<"nt1. Asia"; cout<<"nt2. Europe"; cout<<"nt3. South America"; cout<<"ntInput Your Choice: "; cin>>universe.continental; // dalam pemanggilan objek dari suatu class, // harus diawali oleh inisial class pemiliknya if ( universe.continental == 1 ) // itu biar jelas, kita akan memanggil objek universe.Asia(); // dari kelas yang mana else if ( universe.continental == 2 ) // ingat, pemanggilan objek harus diawali universe.Europe(); // inisial dari class-nya else if ( universe.continental == 3 ) // jadi ketentuannya: inisial.objek universe.SouthAmerica(); // ingat, ADA TITIK SETELAH INISIAL CLASS else return 0; } keterangan: • public merupakan keterangan akses untuk suatu variabel atau method. Public berarti perintah atau variabel atau method tersebut dapat dipanggil di dalam class lain. Ada 3 jenis access identifier, yaitu: ◦ public seperti yang sudah dijelaskan di atas ◦ protected hanya dapat dipanggil di class itu sendiri dan class turunannya ◦ private hanya dapat dipanggil di class itu sendiri
  • 6. IDE : Code::Blocks Compiler : gcc System : Linux Office Tool : LibreOffice Writer Kontak Lengkap: Muhammad Chairul Umam Email mirulumam@gmail.com mirulumam@outlook.com mirulumam@muslim.com Blog pribadi mirulumam