Features of Object Oriented Programming Part 2 | C ++ Tutorial | Mr. Kishore

Naresh i Technologies
3 Jan 201726:33

Summary

TLDRThis video script by Kishore from Nares introduces the fundamental concepts of Object-Oriented Programming (OOP). It explains the core features of OOP, such as classes, objects, data hiding, encapsulation, inheritance, and polymorphism. The script delves into the comparison between C structures and C++ classes, highlighting the extension of structures into classes with added benefits like data protection and the ability to design complex applications. It also clarifies the difference between structures and classes in C++, emphasizing the private access specifier in classes for secure data handling and the role of member functions in accessing private data, encapsulating the principles of data hiding and encapsulation.

Takeaways

  • 😀 Object-Oriented Programming (OOP) is a programming paradigm that uses 'classes' and 'objects' to design applications.
  • 🏫 The concept of 'class' in OOP is an extension of the C structure, allowing the bundling of data and functions together.
  • 🔒 Data hiding in OOP is achieved by using private access specifiers, restricting access to class data members to only member functions within the same class.
  • 📦 Encapsulation is the process of binding data and associated functions into a single unit, which is the class, providing a way to bundle data and methods that operate on the data.
  • 🔑 Inheritance is a key feature of OOP that allows a new class to inherit properties and behaviors (methods) from an existing class.
  • 📈 Polymorphism allows objects to be treated as instances of their parent class rather than their actual class, enabling a single interface to be used for a general class of actions.
  • 🔄 Message communication is the mechanism by which objects interact with each other in OOP, typically through method calls.
  • 📌 The 'structure' in C language is a collection of heterogeneous variables and is the foundation for OOP concepts, but lacks data protection and complex program design capabilities.
  • 🔄 C++ extends the concept of structures by allowing the declaration of member functions and access specifiers, but still has the limitation of public data by default.
  • 🛡️ The introduction of 'class' in C++ addresses the shortcomings of structures by providing private, protected, and public access levels, enhancing data security and supporting complex program design.
  • 🔍 An object in OOP is an instance of a class, representing the physical manifestation of the class blueprint, with allocated memory for its data members when created.

Q & A

  • What does OOP stand for and what are its main features?

    -OOP stands for Object-Oriented Programming. Its main features include class, object, data hiding, encapsulation, inheritance, polymorphism, and message communication.

  • What is a class in the context of OOP?

    -A class in OOP is an extension of a C structure. It is a user-defined data type that allows the bundling of data and functions together into a single unit, which can then be used to create objects.

  • What is the difference between a C structure and a C++ structure?

    -In C, structures can only contain variables, whereas in C++, structures can also contain member functions along with variables. However, by default, both C and C++ structures have public data members, which can be accessed from anywhere in the program.

  • Why were classes introduced in C++?

    -Classes were introduced in C++ to address the issue of data protection that is not available in structures. Classes allow for the encapsulation of data and functions, and they support access specifiers like private, which restrict access to class members from outside the class.

  • What is the concept of data hiding in OOP?

    -Data hiding in OOP is the practice of making class data members private, so they can only be accessed and modified by the class's member functions. This prevents unauthorized access and modification of the data from outside the class.

  • What is encapsulation and how is it achieved in a class?

    -Encapsulation is the process of binding data and the associated functions together into a single unit or class. It is achieved by declaring data members and member functions within a class and using access specifiers to control access to these members.

  • What is an object in OOP?

    -An object in OOP is an instance of a class. It is a variable of the class type and represents the physical manifestation of the class blueprint, holding actual data and being able to perform actions defined by its member functions.

  • How does a class act as a blueprint for creating objects?

    -A class acts as a blueprint by defining the structure and behavior of the objects that can be created from it. When an object is instantiated from a class, memory is allocated for the object's data members, and the object can access the class's member functions.

  • What is the default access level for members in C++ classes and structures?

    -In C++, the default access level for members in a class is private, whereas in C++ structures, the default access level is public.

  • Why are structures not suitable for designing large applications?

    -Structures are not suitable for designing large applications because they do not support the concept of inheritance, which is crucial for creating extensible and maintainable code in large projects. Classes, on the other hand, support inheritance along with encapsulation and data hiding.

  • Can you access private data members of a class from outside the class?

    -No, private data members of a class cannot be accessed from outside the class. They can only be accessed and modified through the class's member functions, ensuring data hiding and encapsulation.

Outlines

00:00

📘 Introduction to Object-Oriented Programming Concepts

This paragraph introduces the concept of Object-Oriented Programming (OOP), explaining its fundamental features such as class, object, data hiding, encapsulation, inheritance, polymorphism, and message communication. It emphasizes the importance of the 'class' concept, which extends the C structure, allowing for the grouping of heterogeneous variables under one name. The paragraph sets the stage for a deeper dive into the specifics of OOP, starting with the class concept and its relation to C structures.

05:01

🏭 Understanding C Structures as the Foundation of OOP

The speaker elaborates on C structures, which serve as the basis for OOP. A structure is a user-defined data type that can hold a collection of heterogeneous variables, making it an essential component for constructing objects in OOP. The paragraph provides an example of a 'student' structure, illustrating how it can store a student's ID, name, and subject-wise marks. It also discusses the memory allocation for structure variables and the process of accessing structure members. However, it points out the limitation of C structures, which is the lack of data protection due to public accessibility by default.

10:04

🔒 Transitioning from C Structures to C++ Classes for Enhanced Data Security

This paragraph discusses the transition from C structures to C++ classes, highlighting the introduction of data encapsulation and access specifiers like private, public, and protected in C++. It explains that while C++ structures can include member functions and have access specifiers, they lack the capability for complex program design and do not support inheritance, unlike classes. The paragraph emphasizes the importance of classes in C++ for creating secure and scalable applications due to their ability to restrict data access and support object-oriented features like inheritance.

15:07

🔑 The Role of Classes in Data Hiding and Encapsulation

The speaker explains the concept of data hiding and encapsulation in the context of C++ classes. Data hiding is achieved by declaring class members as private, restricting access to them by outside entities and allowing access only through member functions of the same class. Encapsulation is described as the bundling of data members and member functions into a single unit, which is the class. The paragraph provides an example of a 'student' class with private data members and a public member function to access them, illustrating how classes facilitate secure and organized code design.

20:09

🏗️ Class as a Blueprint and Object as an Instance in OOP

This paragraph delves into the distinction between classes and objects in OOP. It describes a class as a blueprint or an original copy from which multiple instances, or objects, are created. The class defines the structure and behavior of the objects, while objects are the actual instances that carry out the class's defined actions and store its data. The speaker uses the analogy of a blueprint for a building to explain the relationship between classes and objects, emphasizing that memory is allocated for objects only when they are created, not when the class is defined.

25:10

🎭 The Physical Representation of Objects in OOP

The final paragraph reinforces the concept of objects as the physical representation of a class. It reiterates that classes are logical constructs defining the properties and methods, while objects are the tangible entities that embody these definitions. The speaker likens the class to a blueprint and objects to the actual copies or instances made from that blueprint. This paragraph wraps up the session by summarizing the key points discussed about OOP features and their significance in software development.

Mindmap

Keywords

💡Object-Oriented Programming (OOP)

OOP stands for Object-Oriented Programming, a programming paradigm that uses 'objects' to design applications and software. It is the central theme of the video, as it discusses the features and concepts of OOP. The script explains that OOP is based on the idea of a 'class', which is a blueprint for creating objects, and it also covers other key OOP features like inheritance and encapsulation.

💡Class

In the context of the video, a 'class' is defined as an extension of the C structure, serving as a blueprint for creating objects. It is a user-defined data type that allows the bundling of data and functions together. The script illustrates the concept of a class by comparing it to a structure in C, highlighting that classes in C++ can include both data members and member functions, unlike C structures.

💡Object

An 'object' is an instance of a class. The video script explains that objects are created from classes and are variables of a class type. They represent the physical manifestation of the class blueprint, allocating memory for the data members defined in the class. The script uses the example of a 'student' to illustrate how objects store related data for individual instances.

💡Data Hiding

Data Hiding is a principle in OOP that restricts direct access to some of an object's components, which is a form of encapsulation. The video script discusses how in C++, class data members are private by default, meaning they can only be accessed through member functions of the same class. This concept is crucial for creating secure and modular code.

💡Encapsulation

Encapsulation is the process of bundling the data (attributes) and methods (functions) into a single unit or class. The video script explains that encapsulation is achieved by using private access specifiers in classes, which bind data and functions together, preventing unauthorized access and maintaining integrity.

💡Inheritance

Inheritance is a fundamental concept in OOP that allows a new class to take on the properties and methods of an existing class. Although not explicitly detailed in the script, it is mentioned as one of the OOP features, and it is implied that classes facilitate inheritance, unlike C structures.

💡Polymorphism

Polymorphism is another key OOP feature that allows objects to be treated as instances of their parent class rather than their actual class. The script mentions polymorphism as one of the features of OOP, suggesting that it is a concept that enables objects to be used interchangeably in the context of a program.

💡Message Communication

Message Communication refers to the method by which objects interact with each other in OOP. The script lists it as one of the OOP features, indicating that it is a way for objects to send and receive messages, which is a form of inter-object communication.

💡Structure

A 'structure' in C is a collection of heterogeneous variables, allowing different types of variables to be stored under one name. The video script uses the concept of structures to lay the foundation for understanding classes in C++. It explains that structures in C are public by default and do not support functions, which is a limitation that classes overcome.

💡User-Defined Data Type

The term 'user-defined data type' is used in the script to describe structures and classes, which are types that are not built into the language but are created by the programmer to suit specific needs. The script explains that structures and classes are user-defined because they allow the programmer to define how data is organized and accessed.

💡Member Function

A 'member function' is a function declared inside a class in C++. The script explains that member functions are used to access the private data members of a class. They are an integral part of encapsulation, as they provide the only means of accessing and modifying private class data.

Highlights

Introduction to Object-Oriented Programming (OOP) and its features such as class, object, data hiding, encapsulation, inheritance, polymorphism, and message communication.

Explanation of 'class' as an extension of C structures, emphasizing the role of structures as the foundation for OOP.

Description of a structure as a collection of heterogeneous variables, allowing for the storage of different types of variables under one name.

Differentiation between primitive and derived data types in C language, with structures allowing the declaration of both types.

The concept of user-defined data types, with structures being an example due to their customizable nature based on requirements.

Illustration of how to use structures to store related data, such as student data including ID, name, and subject-wise marks.

The problem with C structures being that their data is public by default, leading to a lack of data protection.

Introduction of the class concept in C++ to address the issue of public structure data and to enable secure data handling.

Difference between C and C++ structures, with C++ allowing the declaration of member functions and access specifiers within structures.

The inherent issue with C++ structures being unable to design complex programs due to their public data by default.

The class in C++ as a blueprint for creating objects, with private data members being accessible only through member functions.

Concept of data hiding in classes, achieved by making data members private and accessible only via member functions.

Encapsulation defined as the binding of data members and member functions into a single unit, which is the class.

The role of objects as instances of a class, representing the physical realization of the logical class blueprint.

Explanation of how objects are created from classes and how memory is allocated for them, distinguishing between class and object.

The remaining OOP features to be covered in the subsequent session, indicating a continuation of the topic.

Transcripts

play00:01

[Music]

play00:09

welcome to Nares this is Kishore and

play00:13

today we are going to start object

play00:16

oriented Futures yesterday we have

play00:19

discussed one concept that is what

play00:22

objectoriented programming okay now we

play00:25

are going to start object oriented

play00:28

features what are the features available

play00:30

in oops concept means oop oop stands for

play00:35

objectoriented programming now in oop

play00:38

concept the first main thing is class

play00:42

later second one is nothing but object

play00:46

next data hiding next encapsulation next

play00:51

inheritance polymorphism message

play00:54

Communications like this the whoops

play00:57

features are we're having several okay

play01:00

we are having several oops features what

play01:03

they are one is nothing but class now

play01:07

I'm going to start what is a class and

play01:10

later we are going to discuss about

play01:12

object later what is called Data hiding

play01:16

what is called encapsulation everything

play01:18

now we are going to start first uh the

play01:21

whoops future that is nothing but

play01:25

class now what is a class simply class

play01:29

is is the extension of C structure okay

play01:34

then that means we have to discuss about

play01:37

C structure little bit generally in C

play01:40

language generally in C language

play01:43

structure means collection of

play01:46

heterogeneous variables that means a

play01:49

structure allows to store different

play01:52

types of variables at one place under

play01:57

one name okay okay that's why it is very

play02:01

easy to construct object oriented

play02:05

programming okay that's why generally

play02:08

structures are the foundations for okay

play02:10

structures are the foundations for

play02:13

object oriented Concepts that means here

play02:17

in object oriented programming we are

play02:19

going to use the class but that class is

play02:22

derived from means class is the

play02:25

extension of C structure that's why

play02:29

first time I'm going to discuss about

play02:31

the C structure later we are going to

play02:33

start the class concept now structure

play02:37

means what it is collection of

play02:39

heterogeneous variables okay otherwise

play02:42

in other terms a structure is a user

play02:46

defined data type and why it is called

play02:49

user defined data types because of there

play02:52

is a cause generally in C language we

play02:55

are going to use some primitive data

play02:57

types as well as we are going to use use

play03:00

some derived data types for example

play03:02

primitive data types means integers

play03:05

float character now derived data type

play03:08

means AR pointers and functions now we

play03:12

are able to declare both

play03:16

the Primitive and derived data type at

play03:21

one place using the structure concept

play03:25

for example I want to store some student

play03:28

data means I want want to store one

play03:30

particular student data now generally

play03:34

every student contains what id number

play03:37

name subject wise marks generally I have

play03:40

to declare like this

play03:43

suppose in ID just assume it is nothing

play03:48

but the main

play03:49

function now it is a main function and

play03:52

the main function contains student ID

play03:56

next student name

play04:00

next every student is having subject

play04:03

wise marks okay for example one student

play04:07

is having six subjects now I have to

play04:10

declare what six subjects suppose S1

play04:15

S2 and

play04:17

S6 here I have to declare six variables

play04:21

for six subjects okay instead of this

play04:25

can I declare array yes it is hone now

play04:29

now in place of normal variables I'm

play04:32

going to use

play04:34

AR okay now here I can declare employee

play04:38

details everybody that means they're

play04:41

nonrelated data that means this program

play04:43

allows to store nonrelated data but I

play04:46

want to make it related that means I

play04:49

want to store only the student data at

play04:53

one place okay then in place of main

play04:57

function I'm going to start

play05:01

structure suppose structure name is

play05:03

student now see this it is the student

play05:07

structure and the student structure

play05:09

contains first thing is id id is of

play05:13

integer type and

play05:15

S6 actually we are calling array okay

play05:19

here ID is a normal variable and S is a

play05:23

array type variable now here the point

play05:26

is ID is a primitive data type and AR is

play05:31

a derived data type now we are able to

play05:34

store both primitive and derived data

play05:38

type under one name called structure

play05:42

okay that means the total structure is

play05:44

constructed by the user based on the

play05:49

requirement that's why structure is

play05:52

called it is a user defined data type

play05:56

that's why structure is called it is a

play05:58

user defined data type next a structure

play06:02

is also called complex data type because

play06:04

of different types of variables are

play06:06

stored under one name at one place okay

play06:10

and due to this Advantage is what we can

play06:13

maintain object oriented data means what

play06:17

for example here it is the struct

play06:20

keyword that denotes what we are going

play06:23

to start a structure structure name and

play06:26

structure members they are called and

play06:28

here to work with this structure I'm

play06:31

going to declare some variables like

play06:34

this suppose S10 now what happens here

play06:39

S1 S2 S10 are called structure

play06:44

variables generally variables are stored

play06:47

in stack that's why here just assume it

play06:51

is the stack now it is the stack and

play06:55

first structure variable S1 now this S1

play06:58

require how many byes okay here ID is

play07:02

the integer that's why it takes two

play07:04

bytes and here S6 is six integers that's

play07:08

why it require 12 btes now I'm going to

play07:12

reduce this now three s of 3 now what

play07:16

happened ID requires 2 bytes s of Three

play07:19

6 bytes and name 20 that's why memory is

play07:23

allocated like

play07:24

this now it is a s one first two bytes

play07:28

are allocated for ID now two

play07:33

byes and later s of three is there now

play07:37

what happen watch it here structure name

play07:40

is what structure variable name S1 and

play07:43

array name is yes now yes and three

play07:48

integers memory allocated that means

play07:51

total 6 bytes memory allocated and Base

play07:56

address passord to yes and now

play07:59

later name also there now now it is the

play08:03

name and it requires total 20 bytes

play08:08

that's why total this structure size is

play08:11

28 bytes now the compiler is indicating

play08:16

28 bytes required for this

play08:19

structure okay like this the memory is

play08:22

allocated for structure variables now to

play08:26

access these members we are using S1 do

play08:28

ID S1 do name S1 do subjects okay it is

play08:33

a common thing and now structure allows

play08:36

to store the data like this suppose it

play08:39

is S1 structure data means here we are

play08:42

able to store one student data one

play08:45

student Marks One student name that

play08:48

means all they are related to one

play08:51

student here that one student is called

play08:54

one object next S2 also same that S2

play08:58

allows to store

play08:59

second student data S3 S4 like this now

play09:03

it is called object oriented that's why

play09:07

structures are the

play09:09

foundation now what is the problem with

play09:12

structure okay now we are going to

play09:14

discuss what is the disadvantage in

play09:17

structure now the problem is in C

play09:20

language in C language the structure

play09:24

data is by default

play09:27

public it is the main problem

play09:30

that means what okay now the structure

play09:33

data is accessible from anywhere in our

play09:36

program through the structure variables

play09:39

that means outside members other members

play09:43

or member functions or functions anybody

play09:46

can access the structure data that's why

play09:50

structure data is not protected because

play09:54

of structure data is public by default

play09:57

structure members are public

play10:00

okay now to avoid this problem they have

play10:04

introduced the concept of class and one

play10:08

more thing is in C++ also we are having

play10:12

structures okay here the point is

play10:14

actually we have discussed about C

play10:16

language structure and actually our

play10:18

topic is what C++ now we are having

play10:21

structures in C++ also now what is the

play10:24

difference okay in C language inside the

play10:28

structure we are able to declare only

play10:32

the variables which are called structure

play10:37

members in C language inside the

play10:40

structure we are able to declare only

play10:43

the structure members means only the

play10:46

variables only but in

play10:50

C++ in C++ structure we can

play10:55

declare strcture members and member

play10:58

function

play11:00

also it is the major

play11:03

difference okay now we are able to

play11:06

declare data members generally called

play11:09

Data members okay which are also called

play11:12

structure members and now C++ structure

play11:15

allows to declare both the variables and

play11:19

function inside the structure but C

play11:22

structure never allows this kind of

play11:25

Declaration it is the only difference

play11:27

between C structure and C ++ structure

play11:30

but here one point we have to discuss

play11:33

that is what in C++ also the structure

play11:37

data is public that means anybody can

play11:41

access from anywhere that's why

play11:44

structure data is not secured that's why

play11:48

to avoid this problem okay they have

play11:53

introduced class Concept in

play11:56

C++ now in C++ how how the data is

play12:00

secured that's why they have designed

play12:02

the class like this the class data is

play12:05

divided into private protected public

play12:09

members in see there is no private

play12:12

public protected only public is there

play12:15

and in C++ structure also we are having

play12:18

private protected public but here one

play12:21

important thing is there what is that

play12:24

thing okay here in C++ structure okay we

play12:29

are are not able to Define complex

play12:32

programs with the C++ structures we are

play12:35

not able to design complex programs

play12:38

means big project works but it is

play12:40

possible with the class concept because

play12:44

of classes allows the concept of

play12:48

inheritance okay first observe it

play12:50

carefully here one point is there

play12:53

structure is available in C language and

play12:56

all the structure members are public by

play12:59

default in C language and C structure

play13:02

allows only the variables inside the

play13:05

structure which are called structure

play13:08

members okay and now it is not protected

play13:11

structure data is not protected now in

play13:14

C++ what happened in C++ also they're

play13:18

using structures but the only one

play13:20

difference is okay here they have

play13:24

introduced member functions they have

play13:27

introduced member functions with private

play13:30

public protected

play13:32

declarations but the problem with the

play13:35

C++ structure is they're not able to use

play13:39

for Designing the big applications here

play13:43

big application means project works it

play13:46

is the major problem and here also

play13:49

problem is data is public everybody can

play13:52

access that's why to avoid this problem

play13:56

in C++ which concept is introduced

play13:59

class now what is a class class also

play14:03

extension of C structure now according

play14:05

to this explanation class is the

play14:08

extension of C structure now the

play14:11

difference is what in C++ there is a

play14:14

rule what it is means the private data

play14:17

of a class should be accessed with

play14:21

member functions of same class it is the

play14:24

main thing in previous discussion what

play14:26

happens structure data is structure data

play14:30

is accessed by okay structure members

play14:35

and outers also in C++ structure the

play14:39

structure data is accessed by structure

play14:42

members outers in C structure also the

play14:45

data is accessed by outers that's why C

play14:48

and C++ structure data is not secured

play14:52

that's why they have introduced one

play14:54

formula what it is okay in C++ the price

play14:59

prate data should be accessed only with

play15:03

the member functions of same class now

play15:07

what is called member functions okay

play15:09

here the functions that are declared

play15:11

inside the class are called member

play15:14

functions that means outers are not

play15:17

allowed okay certain rules and the

play15:19

regulations are there that means certain

play15:21

limitations are also there what it is

play15:24

friend function pointers by using friend

play15:27

functions and pointers we can access the

play15:30

class data also but actually the rule is

play15:33

what means the private data should have

play15:36

to access with member functions of same

play15:40

class okay that's why they have designed

play15:43

class now how the class is working see

play15:46

this suppose it is the

play15:50

class suppose student class it is now

play15:55

inside the student class I'm going to

play15:57

use either

play15:59

private or public or

play16:04

protected later I'm going to declare the

play16:08

data

play16:10

members and member

play16:13

functions now class and

play16:16

semicolon see this here it is looking to

play16:19

be the C++ structure now both are having

play16:22

same but the only difference is here

play16:26

private public protected declared now

play16:28

and data members member function

play16:30

declared here also we can but the major

play16:33

difference is they are used in

play16:35

inheritance concept means class allows

play16:38

the concept of inheritance but structure

play16:42

never allows the concept of inheritance

play16:45

and now what happens since based on this

play16:48

I'm going to give one small example

play16:50

Suppose there is a class called

play16:54

St and here I'm not going to mention

play16:58

private or public automatically all the

play17:01

members will become private and here in

play17:05

C++ structure by default all the members

play17:08

are public it is another important

play17:11

difference between structure and class

play17:14

that's why by default structure data is

play17:18

public by default class data is private

play17:22

now when it is private what happens

play17:25

suppose private I'm going to declare

play17:28

like this

play17:30

now it is called visibility label or

play17:32

access specifier later in

play17:36

ID next character name of 20 next in

play17:42

this section I'm going to write one

play17:44

function public or private what it may

play17:46

be then suppose public wi get now inside

play17:53

this function I can access the ID and

play17:55

name using C out and CNR directory what

play17:59

it may be here ID and name are declared

play18:02

inside the class under private and get

play18:06

is declared in public section and inside

play18:09

the get we are asking ID and name okay

play18:13

here I'm going to access the ID and name

play18:17

that means here where we are accessing

play18:19

the data members that is inside the

play18:22

member function here get is called

play18:25

member function why because it is right

play18:27

now member of this class that's why the

play18:30

functions that are

play18:32

declared inside a class are called

play18:35

member functions and with the help of

play18:38

member functions only we can access the

play18:42

private data of a class that means now

play18:46

this data is not accessible from outside

play18:50

the class which is called Data hiding

play18:55

which is called Data hiding okay

play18:59

next it is available to only the member

play19:02

functions and this concept is called

play19:05

Data hiding that's why the key factor of

play19:08

data hiding is achieved with private

play19:12

declarations when the members are

play19:14

private they can be accessed with the

play19:18

member functions okay I'm giving small

play19:20

example generally we are using mobile

play19:22

phones now suppose one mobile phone is

play19:25

there right now it is placed in my

play19:27

pocket and

play19:29

who is going to use this one me and my

play19:33

family members okay and here there is no

play19:36

permission required because of they my

play19:38

family members my members and when it is

play19:42

placed on the road when it is placed

play19:44

outside now it is able to access by any

play19:47

person because of now it is called

play19:50

public okay when it is inside the pocket

play19:53

it is private member that's why private

play19:57

means restrict

play19:59

only authorized people can access when

play20:02

it is on the road means public anybody

play20:06

can access now the structure data is

play20:09

public and class data is private that

play20:12

means outers are not able to access

play20:14

without permission that's why user is

play20:18

able to design secured applications

play20:22

using C++ class concept okay that's why

play20:27

class allows to

play20:29

declare okay class allows to declare

play20:32

both of the variables and functions at

play20:34

one place now the variables are called

play20:37

Data members and functions are called

play20:40

member function that's why here what is

play20:42

happening the data and functions both

play20:45

are

play20:46

associated okay and now according to

play20:49

this explanation class is the

play20:52

combination of data members and member

play20:55

functions that's why simply class is

play20:58

collection of of members that's why here

play21:00

the main point is main point is classes

play21:04

collection of members what kind of

play21:06

members data members and member

play21:08

functions now both are associated

play21:12

together okay into a single unit called

play21:15

class which is called

play21:18

encapsulation that's why encapsulation

play21:21

is the process of binding the data and

play21:26

Associated functions together

play21:29

into a single unit called

play21:33

class this one is possible with class

play21:36

that's why class provides the major

play21:38

concept of data bind hiding data hiding

play21:41

means insulating the data from external

play21:45

access means outers are not allowed only

play21:47

members can access it is called Data

play21:50

hiding second one encapsulation means

play21:54

Binding off or Tiding the data members

play21:57

and member functions into a single unit

play21:59

called class it is nothing but

play22:03

encapsulation future both are provided

play22:06

with class concept that's why here class

play22:09

is a user defined data type with a

play22:13

complex data okay here class is a user

play22:17

defined data type or it is the extension

play22:20

of C structure next here from class we

play22:24

have to declare the variables for

play22:26

example here structure is there there

play22:29

now to access the structure members we

play22:31

should have to declare the structure

play22:33

variables we should have to declare the

play22:36

structure variables then only the memory

play22:38

is allocated in stack similar to that in

play22:41

class also in class also to access the

play22:45

data Members First memory have to be

play22:47

allocated and when it is allocated means

play22:50

when the objects are created now what is

play22:53

called object here we are calling there

play22:56

are structure variables here they are

play22:59

called class variables here called class

play23:03

variables and the class variables are

play23:05

called objects that's why object meaning

play23:09

is what it is a variable of type class

play23:13

for example I'm going to declare like

play23:15

this void

play23:17

main now St s here s is

play23:22

called object now it is nothing but a

play23:26

variable of type class that's why object

play23:29

meaning is class variables now the

play23:33

memory also allocated for s means now s

play23:36

is having data members now for data

play23:39

members the memory is allocated that's

play23:41

why to access the class members we have

play23:43

to declare the objects later to access

play23:47

the object members see this I'm going to

play23:49

access like this for example s do get

play23:53

now it is called

play23:55

calling it is called calling that's why

play23:58

to call or to access the class data

play24:02

members or functions we should have to

play24:04

use the object name now here this object

play24:09

is Created from this class that's why

play24:13

class is a

play24:15

blueprint class is a blueprint to

play24:19

construct the objects okay that's Sol I

play24:23

said class is a user defined data now

play24:26

I'm saying class is a blueprint here

play24:30

blueprint means what original copy

play24:33

blueprint means original copy to

play24:36

construct the gerox copies gerox means

play24:39

what instances now instances mean what

play24:43

copies now the copies are nothing but

play24:46

objects that's why to create the objects

play24:50

we need the class that's why class is a

play24:53

blueprint and object is the instance of

play24:56

a class that's why another definition

play24:59

already we have discussed what object is

play25:02

a class variable now I am saying object

play25:06

is the instance of a class and another

play25:10

definition okay class okay here one

play25:13

small point is there already have given

play25:16

two explanations about object and the

play25:18

next explanation is object is the

play25:22

physical representation of a class

play25:26

object is the physical IAL

play25:29

representation of a class that means

play25:32

what okay here I said class is the

play25:35

blueprint means original copy and

play25:38

objects are the gerox okay here the

play25:41

point is when the object is created then

play25:45

only memory allocated that means

play25:47

according to this example class never

play25:50

takes the memory means when class is

play25:53

created memory not allocated when

play25:56

objects are created then only memory

play25:59

allocated means which requires the

play26:01

memory means object that's why object is

play26:04

the physical and class is The

play26:08

Logical okay it is a major point now it

play26:12

is nothing but what is a class what is

play26:14

an object okay in this session I'm going

play26:18

to cover the remaining whoops features

play26:21

thank you for

play26:25

[Music]

play26:27

watching

play26:30

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
OOP ConceptsC++ ProgrammingData HidingEncapsulationInheritancePolymorphismClass DesignStructuresMember FunctionsObject Creation