SlideShare une entreprise Scribd logo
1  sur  39
Classes & Objects Ms. Ma. Patricia B. Lina
What is a class? ,[object Object]
What is an object? ,[object Object]
Class vs. Object Vehicle Car Animal Elephant Person Student Flower Rose
How to declare a class? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class vs. Struct ,[object Object]
What is an access specifier? ,[object Object],[object Object],[object Object],[object Object]
[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How to access members of a class? ,[object Object],[object Object],[object Object]
 
 
 
Operator of Scope
Operator of Scope
Operator of Scope
Operator of Scope (::)  ,[object Object],[object Object],[object Object]
Inline or Not –inline Function? ,[object Object]
[object Object]
 
Reminders ,[object Object],[object Object]
Constructor ,[object Object]
Constructor ,[object Object],[object Object],[object Object]
 
Destructor ,[object Object]
Destructor ,[object Object],[object Object]
 
Overloading Constructors ,[object Object]
 
Reminder ,[object Object]
Default Constructor ,[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Parameterized Constructor ,[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Copy Constructor ,[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
include "stdafx.h" #include "iostream" using namespace std; class yanyan { public: char name[30]; char status[20]; int hours; float rate; int deductions; float salary; float compute(int hours, float rate, int deductions) { float salary; salary = (hours*rate) - deductions; return (salary); } }; yanyan a[100]; int employee,i;
int _tmain(int argc, _TCHAR* argv[]) { system(&quot;cls&quot;); cout<<&quot;Enter no. of employee: &quot;; cin>>employee; for (i=1;i<=employee;i++) { cout<<&quot;Enter employee name:  &quot;; cin>>a[i].name; cout<<&quot;Status? &quot;; cin>>a[i].status; cout<<&quot;No. of hours worked: &quot;; cin>>a[i].hours; cout<<&quot;Some deductions? &quot;; cin>>a[i].deductions; cout<<&quot;Enter hourly rate: &quot;; cin>>a[i].rate;
a[i].salary=a[i].compute(a[i].hours,a[i].rate,a[i].deductions); cout<<a[i].name; cout<<&quot; with status: &quot;; cout<<a[i].status; cout<<&quot; has a salary of &quot;; cout<<a[i].salary; } system(&quot;pause&quot;); return 0; }

Contenu connexe

Tendances

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 

Tendances (20)

Classes and objects in java
Classes and objects in javaClasses and objects in java
Classes and objects in java
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introduction
 
Object and class
Object and classObject and class
Object and class
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Class introduction in java
Class introduction in javaClass introduction in java
Class introduction in java
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Java
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Java class
Java classJava class
Java class
 
Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...
 
Class or Object
Class or ObjectClass or Object
Class or Object
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
 
Classes and Objects in C#
Classes and Objects in C#Classes and Objects in C#
Classes and Objects in C#
 
Java Methods
Java MethodsJava Methods
Java Methods
 

Similaire à Classes & objects new

3 functions and class
3   functions and class3   functions and class
3 functions and class
trixiacruz
 
+2 CS class and objects
+2 CS class and objects+2 CS class and objects
+2 CS class and objects
khaliledapal
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
lykado0dles
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
rashmita_mishra
 

Similaire à Classes & objects new (20)

Classes-and-Objects-in-C++.pdf
Classes-and-Objects-in-C++.pdfClasses-and-Objects-in-C++.pdf
Classes-and-Objects-in-C++.pdf
 
Class and object
Class and objectClass and object
Class and object
 
My c++
My c++My c++
My c++
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
+2 CS class and objects
+2 CS class and objects+2 CS class and objects
+2 CS class and objects
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Unit vi(dsc++)
Unit vi(dsc++)Unit vi(dsc++)
Unit vi(dsc++)
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
 
Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
 
Lecture 4. mte 407
Lecture 4. mte 407Lecture 4. mte 407
Lecture 4. mte 407
 
object oriented programming language by c++
object oriented programming language by c++object oriented programming language by c++
object oriented programming language by c++
 
C++ Notes
C++ NotesC++ Notes
C++ Notes
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programming
 
Class and object
Class and objectClass and object
Class and object
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
C questions
C questionsC questions
C questions
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 

Dernier

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Classes & objects new

  • 1. Classes & Objects Ms. Ma. Patricia B. Lina
  • 2.
  • 3.
  • 4. Class vs. Object Vehicle Car Animal Elephant Person Student Flower Rose
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.  
  • 12.  
  • 13.  
  • 17.
  • 18.
  • 19.
  • 20.  
  • 21.
  • 22.
  • 23.
  • 24.  
  • 25.
  • 26.
  • 27.  
  • 28.
  • 29.  
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. include &quot;stdafx.h&quot; #include &quot;iostream&quot; using namespace std; class yanyan { public: char name[30]; char status[20]; int hours; float rate; int deductions; float salary; float compute(int hours, float rate, int deductions) { float salary; salary = (hours*rate) - deductions; return (salary); } }; yanyan a[100]; int employee,i;
  • 38. int _tmain(int argc, _TCHAR* argv[]) { system(&quot;cls&quot;); cout<<&quot;Enter no. of employee: &quot;; cin>>employee; for (i=1;i<=employee;i++) { cout<<&quot;Enter employee name: &quot;; cin>>a[i].name; cout<<&quot;Status? &quot;; cin>>a[i].status; cout<<&quot;No. of hours worked: &quot;; cin>>a[i].hours; cout<<&quot;Some deductions? &quot;; cin>>a[i].deductions; cout<<&quot;Enter hourly rate: &quot;; cin>>a[i].rate;
  • 39. a[i].salary=a[i].compute(a[i].hours,a[i].rate,a[i].deductions); cout<<a[i].name; cout<<&quot; with status: &quot;; cout<<a[i].status; cout<<&quot; has a salary of &quot;; cout<<a[i].salary; } system(&quot;pause&quot;); return 0; }