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
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; }
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