SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Class And Object
C++
Class And Object
Paradigm:A Method to Design Program.
POP(Procedural oriented
programming)
OOP(Object Oriented
Programming)
Event Dreiver
Class And Object
 POP(Procedural oriented programming):
program is divided into sub programs or modules and then assembled to form a
complete program. These modules are called functions.
• Importance is give to procedural.
• Modules(Modural Programming).
 Draro back:data was ignore.
 They were not modeling real would.
Class And Object
Class And Object
 OOP(Object Oriented Programming):Language baesd concepts of class and object.
And follow the principle
Of OOP’s
Character stices behavior
Abstraction,Encapsulation,Inheritence,Polymorphism,
Object (data)
Variables+Function
Classes
Example
class Test
{
private:
int data1;
float data2;
public:
void function1()
{ data1 = 2; }
float function2()
{
data2 = 3.5;
return data2;
}
};
Class And Object
Class And Object
Class:Collection of object of same type.
Class is a blue print of object.
Class is a user defined data type.
Class is collection of variable and function.
Object:
Any identifiable entity.
Instance of class
Memory in allocated to class after object creation.
Class And Object
Syntax of class:
Class {
data members;
members function;
};
Class classname{
Private:
.
.
Public:
.
.
Protected:
.
.
}
Class And Object
Object:Object is real entity word.with the help of object we can call the
member +data and member fuction.It is just a membership.
Syntax of Object:
Class name classobject;
Classobject.meberfunction();
Example
//Class name is Car
class Car
{
//Data members
char name[20];
int speed;
int weight;
public: //Functions
void brake(){
}
void slowDown(){
}
};
int main()
{ //ford is an object
Car ford; }
Example
class Test
{private:
int data1;
float data2;
public:
void function1()
{ data1 = 2; }
float function2() {
data2 = 3.5;
return data2; } };
int main()
{ Test o1, o2; }
Access Specifier keywords
Assess specifire keywords that specify the accessibility of a member of class.
 Private
 Public
 protected
Access Specifier
 Private:-Member declared with keyword private are known as private main
class and are not asscessable outside the class.
 Public:Public member declared with keyword public member of class and can
be access any were in the program.
 Protected:protected member declared with key protected are known as
protected and are accessable eith in sub class only
Example
/* C++ program to create a simple class and object.*/
#include <iostream>
using namespace std;
class Hello{
public:
void sayHello() {
cout << "Hello World" << endl;
}};
int main(){
Hello h;
h.sayHello();
return 0;
}
Scope resolution operator :-(::)
//C++ Program to show that scope resolution oprater is used.
// to difine a function outside a class.
::-Scope resolution used with the member which are declared inside class but
define outside the class .
It specifies the scope of member of class.
Filename scope.cpp

Weitere ähnliche Inhalte

Was ist angesagt?

Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 

Was ist angesagt? (20)

Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
OOP java
OOP javaOOP java
OOP java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
 
Method overriding
Method overridingMethod overriding
Method overriding
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 

Ähnlich wie Class or Object

C++ largest no between three nos
C++ largest no between three nosC++ largest no between three nos
C++ largest no between three nos
krismishra
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
farhan amjad
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
Jay Patel
 
Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)
Asfand Hassan
 
Application package
Application packageApplication package
Application package
JAYAARC
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
rani marri
 

Ähnlich wie Class or Object (20)

oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3
 
Object Oriented Programming Constructors & Destructors
Object Oriented Programming  Constructors &  DestructorsObject Oriented Programming  Constructors &  Destructors
Object Oriented Programming Constructors & Destructors
 
C++ largest no between three nos
C++ largest no between three nosC++ largest no between three nos
C++ largest no between three nos
 
Lecture 4. mte 407
Lecture 4. mte 407Lecture 4. mte 407
Lecture 4. mte 407
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 
Lab 4 (1).pdf
Lab 4 (1).pdfLab 4 (1).pdf
Lab 4 (1).pdf
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)
 
oopm 2.pdf
oopm 2.pdfoopm 2.pdf
oopm 2.pdf
 
Application package
Application packageApplication package
Application package
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
 
My c++
My c++My c++
My c++
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
CS3391 -OOP -UNIT – II NOTES FINAL.pdf
CS3391 -OOP -UNIT – II  NOTES FINAL.pdfCS3391 -OOP -UNIT – II  NOTES FINAL.pdf
CS3391 -OOP -UNIT – II NOTES FINAL.pdf
 
Oop(object oriented programming)
Oop(object oriented programming)Oop(object oriented programming)
Oop(object oriented programming)
 

Kürzlich hochgeladen

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 

Kürzlich hochgeladen (20)

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 

Class or Object

  • 2. Class And Object Paradigm:A Method to Design Program. POP(Procedural oriented programming) OOP(Object Oriented Programming) Event Dreiver
  • 3. Class And Object  POP(Procedural oriented programming): program is divided into sub programs or modules and then assembled to form a complete program. These modules are called functions. • Importance is give to procedural. • Modules(Modural Programming).  Draro back:data was ignore.  They were not modeling real would.
  • 5. Class And Object  OOP(Object Oriented Programming):Language baesd concepts of class and object. And follow the principle Of OOP’s Character stices behavior Abstraction,Encapsulation,Inheritence,Polymorphism, Object (data) Variables+Function Classes
  • 6. Example class Test { private: int data1; float data2; public: void function1() { data1 = 2; } float function2() { data2 = 3.5; return data2; } };
  • 8. Class And Object Class:Collection of object of same type. Class is a blue print of object. Class is a user defined data type. Class is collection of variable and function. Object: Any identifiable entity. Instance of class Memory in allocated to class after object creation.
  • 9. Class And Object Syntax of class: Class { data members; members function; }; Class classname{ Private: . . Public: . . Protected: . . }
  • 10. Class And Object Object:Object is real entity word.with the help of object we can call the member +data and member fuction.It is just a membership. Syntax of Object: Class name classobject; Classobject.meberfunction();
  • 11. Example //Class name is Car class Car { //Data members char name[20]; int speed; int weight; public: //Functions void brake(){ } void slowDown(){ } }; int main() { //ford is an object Car ford; }
  • 12. Example class Test {private: int data1; float data2; public: void function1() { data1 = 2; } float function2() { data2 = 3.5; return data2; } }; int main() { Test o1, o2; }
  • 13. Access Specifier keywords Assess specifire keywords that specify the accessibility of a member of class.  Private  Public  protected
  • 14. Access Specifier  Private:-Member declared with keyword private are known as private main class and are not asscessable outside the class.  Public:Public member declared with keyword public member of class and can be access any were in the program.  Protected:protected member declared with key protected are known as protected and are accessable eith in sub class only
  • 15. Example /* C++ program to create a simple class and object.*/ #include <iostream> using namespace std; class Hello{ public: void sayHello() { cout << "Hello World" << endl; }}; int main(){ Hello h; h.sayHello(); return 0; }
  • 16. Scope resolution operator :-(::) //C++ Program to show that scope resolution oprater is used. // to difine a function outside a class. ::-Scope resolution used with the member which are declared inside class but define outside the class . It specifies the scope of member of class. Filename scope.cpp