KEMBAR78
CLASS and Objects | PDF | Class (Computer Programming) | Method (Computer Programming)
0% found this document useful (0 votes)
37 views17 pages

CLASS and Objects

This document discusses classes and objects in C++. It defines a class as a template that specifies the form and behavior of objects, and defines an object as an instance of a class that stores its own set of data values and supports operations to access that data. The document outlines key concepts like class declaration, defining objects, accessing member functions, static data members, and the relationship between arrays and classes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views17 pages

CLASS and Objects

This document discusses classes and objects in C++. It defines a class as a template that specifies the form and behavior of objects, and defines an object as an instance of a class that stores its own set of data values and supports operations to access that data. The document outlines key concepts like class declaration, defining objects, accessing member functions, static data members, and the relationship between arrays and classes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Topic

CLASS
AND
OBJECTS.

By Hardeep Singh
CONTENTS
 Definition of Class
 Declaration of class
 Definition of object
 Relationship of class and
object
 Accessing a member
function
 Arrays and classes
 Class and object scope
 Static data member
 Static member function
By Hardeep Singh
DEFINITION OF
CLASS

Example
Fruit Mango

Class Object

By Hardeep Singh
DECLARATION OF
CLASS

 Class Tag Name


 Data member
 Member Function
 Program Access Level
a) Private
b) Public

By Hardeep Singh
SYNTAX OF CLASS

Class class-name
{
private:
data member
public:
member function
};

By Hardeep Singh
DEFINITION OF
OBJECT

Object may represent


 A person
 A place
 A bank account
 A table

By Hardeep Singh
ACCESSING A
MEMBER
FUNCTION

The general format is allow:


1.Object-name.data member
2.Object-name.member
function

By Hardeep Singh
CLASS METHOD
DEFINITION

 The member function Is


defined a two types :
i. Inside the class definition
ii. Outside the class definition

By Hardeep Singh
OUTSIDE THE
CLASS DEFINITION

Syntax:
return-type class-name ::
function-name(argument
declaration)
{
function body;
}

By Hardeep Singh
ARRAYS AND
CLASSES

Arrays and Classes have two


types of relationship:
1. Array with class
2. Array of objects

By Hardeep Singh
ARRAY WITH CLASS

Syntax:
class class-name
{
private:
data-type array-name;
public:
data member[size];
member function;
};
class class-name object list;
By Hardeep Singh
ARRAY OF
OBJECTS
Syntax:
class class-name or tag-name
{
private:
data member;
member function;
public:
data member;
member function;
};
class class-name object[size];
By Hardeep Singh
CLASS AND
OBJECT SCOPE
They are two types of classes
and two types of objects as
written below:
1. Local class
2. Global class
3. Local object
4. Global object

By Hardeep Singh
LOCAL CLASS
Example:
void test(int a) // function
{
------;
class student // local class
{
-------------; // class
definition
};
-----------;
student s1(); //create object
} By Hardeep Singh
STATIC MEMBER

Example:
class item
{
static int count; // static declare
int number;
public:
void getdata();
void getcount();
}; By Hardeep Singh
STATIC MEMBER
FUNCTION

Syntax:
 class-name :: function-
name;

By Hardeep Singh
Thanks
Any ?

By Hardeep Singh

You might also like