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

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome to nourish 80 this is Kishore and today we are going to start object-oriented futures yesterday we have discussed one concept that is what object-oriented programming okay now we are going to start object-oriented features what are the features available in oops concept means Opie Opie stands for object-oriented programming now in OOP concept the first main thing is a class later second one is nothing but object next data hiding next encapsulation next inheritance polymorphism message communications like this the whoops features are we are having several okay we are having several view poops features what they are one is nothing but a class now I am going to start what is a class and later we are going to discuss about object later what is called data hiding what is called an encapsulation everything now we are going to start first the whoops feature that is nothing but class now what is a class simply class is the extension of C structure okay then that means we have to discuss about C structure little bit generally in C language generally in C language structure means collection of heterogeneous variables that means a structure allows to store different types of variables at one place under one name okay okay that is why it is very easy to construct a object-oriented programming okay that is why generally structures are the foundations for okay structures are the foundations for object-oriented concepts that means here in object-oriented programming we are going to use the class but that class is derived from means a class is the extension of a/c structure that is why first I am going to discuss about the C structure later we are going to start the class concept now structure means what it is collection of heterogeneous variables okay otherwise in other terms a structure is a user-defined data type and why it is called user-defined data types because of there is a cause generally in C language we are going to use some primitive data types as well as we are going to use some derived data types for example primitive data types means integers float character now derived data type means terasu pointers and functions now we are able to declare both the primitive under derived data type at one place using the structure concept for example I want to store some student it means I want to store one particular student data now generally every student contains what ID number name of subject vice marks generally how to declare like this suppose I NTID just as you it is nothing but the main function now it is a main function and the main function contains student ID next student name next every student is having subject wise marks okay for example one student is having six subjects now I have to declare what six subjects suppose s 1 s 2 and s 6 here how to declare six variables for 6 subjects ok instead of this can I declare array yes it is alone now in place of normal variables I am going to use array okay now here I can declare employee details everybody that means they are non related data that means this program allows to store non related data but I want to make it related that means I want to store only the student data at one place okay then in place of main function I am going to start structure suppose structure name is student now say this it is the student structure and the student structure contains first thing is ID IDs of integer type and es6 actually we are calling array okay here ID is a normal variable and s sees a array type variable now here the point is ID is a primitive data type under array is a derived data type now we are able to store both the primitive under derived data type under one name called structure okay that means the total structure is constructed by the user based on the requirement that is why structure is called it is a user defined data type that is why structure is called it is a user defined data type next structure is also called complex data type because of different types of variables are stored under one name at one place okay and due to this advantage is what we can maintain object-oriented data means what for example here it is the struct keyword that denotes what we are going to start a structure structure name and structure members they are called and here to work of it to this structure I am going to declare some variables like this suppose is 10 now what happens here s 1 s 2 s 10 or called structure variables generally variables are storing back that is why here just assume it is the stack now it is the stack and first structure variable s1 now this s1 require how many bytes okay here I D is the integer that is why it takes to it and here s6 is a six integers that is why it requires 12 right now I am going to reduce this now 3s off thing now what happened I D requires two whites s of 3 6 bytes unnamed 20 that is why memory is allocated like this now it is a s 1 first 2 bytes are allocated for ID now to whites and later s of 3 is there now what happens watch it here structure name is what structure variable name s 1 and our enemies yes now s & 3 integers memory allocated that means total 6 bytes memory allocated and the base address possible - yes and now later name also there no now it is the name and it requires total 20 bytes that is why total this structure size is 28 bytes now the compiler is indicating 28 bytes required for this structure okay like this the memory is allocated for structure variables now to access these members we are using s 1 dot ID s 1 dot name s 1 dot subjects ok it is a common thing and now structure allows to store the data like this suppose it is s 1 structure data name sir here we are able to store one student data one student marks one student name that means all they are related to one student here that one student is called one object next s to also same that s to ellos to store second student data s3s or like this now it is called a object-oriented that is why structures are the foundation now what is the problem with the structure okay now we are going to discuss what is the disadvantage in structure now the problem is in C language in C language the structure data is by default public it is a main problem that means what okay now the structure data is accessible from anywhere in our program through the structure variables that means outside members other members are member functions or functions anybody can access the structure data that is why structure data is not protected because of structure data is public by default such our members are public okay now to avoid this problem they have introduced the concept of a class and one more thing is in C++ also we are having structures okay here the point is actually we have discussed about C language structure and actually our topic is what C please please now we are having structures in C blackness also now what is the difference okay in C language inside the structure we are able to declare only the variables which are called structure members in C language inside the structure we are able to declare only the structure members means only the variables only but in C++ in C++ structure we can declare such are members under number functions also it is the major difference okay now we are able to declare data members generally called data members okay which are also called structure members and now C++ structure allows to declare both to the variables and the forms inside the structure but see structure never allows this kind of declaration it is the only difference between see structure and shapeless play structure but here one point we have to discuss that is what in C++ also the structure data is public that means anybody can access from anywhere that is why structured data is not secure that is why to avoid this problem they have introduced a class concept in C++ now in C++ how the data is secured up that is why they have designed the class like this the class data is divided into private protected public members in C there is no private public protected only public is there and in C++ structure also we are having private protected public but here one important thing is there what is that thing okay here in C++ structure okay we are not able to define complex programs with the C++ structures we are not able to design complex programs means big project works but it is possible with the class concept because of classes allows the concept of inheritance okay first observe it carefully here one point is their structure is available in C language and all the structure members are public by default in C language and C structure allows only the variables inside the structure which are called structural members okay and now it is not protected structure data is not protected now in C++ what happened in C++ also they're using structures but the only one difference is okay here they have introduced member functions they have introduced a number functions with the private public protected declarations but the problem with the C++ structure is they are not able to use for designing the big applications here big application means project works it is the major problem and here also problem is data is public everybody can access that is why to avoid this problem in C++ which concept is introduced class now what is a class class also extension of C structure now according to this explanation class is the extension of C structure now the difference is what in C++ there is a rule what it is means the private data of a class should be accessed with the member functions of same class it is the main thing in previous discussion what happens structure data is structure data is accessed by okay structure members and outers also in C++ structure the structure data is accessed by structure members outers in C structure also the data is accessed by outers that is why C and C++ structure data is not secure that is why they have introduced one formula what it is okay in C++ the private data should be accessed only with the member functions of same class now what is called number functions okay here the functions that are declared inside the class are called member functions that means outers are not allowed okay certain rules and regulations of the that means that the element limitations are also there what it is friend function pointers by using friend functions and pointers we can access the class data also but actually the rule is what means the private data should have to access with member functions of same class okay that is why they have designed class now how the class is working say this suppose it is the class suppose student class it is now inside the student class I am going to use either private or public are protected later I am going to declare the data members and the member functions now class and semicolon see this here it is looking to be the C++ structure now both are having same but the only difference is here private public protected declared and data members member function declare here also we can but the major difference is they are used in inheritance concept means class hellos the concept of inheritance but structure never arose the concept of inheritance and now what happens is based on this I am going to give one small example suppose there is a class called a steal and Here I am NOT going to mention private or public automatically all the members will become private and here in C++ structure by default all the members are public it is the another important difference between structure and class that is why by default structure data is public by default class data is private now when it is private what happens suppose private I am going to declare like this now it is called visibility label or access specifier later int ID next character name of twenty next in this section I am going to write one function public or private what it may be then suppose public wire gate now inside this function I is the ID and name using co2 and CN or directly what it may be here ID and name are declared inside the class under private and the gate is declared in public section and inside the gate we are Xing ID and any okay here I am going to access the ID and name that means here where we are accessing the data members that is inside the number function here gate is called number function why because it is right no member of this class that is why the functions that are declared inside a class or called member functions and with the help of member functions only we can access the private data of a class that means now this data is a not accessible from outside the class which is called data hiding which is called data hiding okay next it is available to only the member functions and this concept is called a data hiding that is why the key factor of data hiding is achieved with the private declarations when the members are private they can be accessed with the member functions okay I am giving small example generally we are using mobile phones now suppose one mobile phone is there right now it is placed in my pocket and who is going to use this one me and my family members okay and here there is no permission required because of their my family members my members and when it is placed on the road when it is placed outside now it is able to access by any person because of now it is called public okay when it is inside the pocket it is private member that is why private means restricted only other easily people can access when it is on the road means public anybody can access now the structure is a public and class data is a private that means outers are not able to access without permission that is why user is able to design secure applications using c++ class concept okay that is why class allows to declare okay class allows to declare both of the variables and functions at one place now the variables are called data members and functions are called member action that is why here what is happening the data and functions both are associated okay and now according to this explanation class is the combination of data members and member functions that is why simply class is a collection of numbers that is why here the main point is main point is class is collection of members what kind of members data members under member functions now both are associated together okay into a single unit called class which is called encapsulation that is why encapsulation is the process of binding the data under Associated functions together into a single unit called class this one is possible with the class that is why class provides the major concept of data by hiding data hiding means insulating the data from external access means outers are not allowed only members can access it is called data hiding second one and capsulation means binding of or tiding the data members and member functions into a single unit called class it is nothing but a encapsulation future both are provided with the class concept that is why here class is a user define early data type with the complex data okay here class is a user-defined data type or it is the extension of C stuck next here from class we have to declare the variables for example here structure is there now to access the structure members we should have to declare the structure variables we should have to declare the structure variables then only the memory is allocated in stack similar to that in class also in class also to access the data members first in memory how to be allocated and when it is allocated means when the objects are created now what is called object here we are calling their structure variables here they are called class variables here called class variables and the class variables are called objects that is why object meaning is what it is a variable of type class for example I am going to declare like this wide may now s tu yes here is called object now it is nothing but a variable of type class that is why object meaning is class variables now the memory also allocated refer s means now s is having data members for data members the memory is allocated that is what axis the class members we have to declare the objects later to access the object number since I am going to axis like this for example yes dot get now it is called calling it is called call that is why to call or pay axis the class data members are functions we should have to use the object name now here this object is created from this class that is why class is a blueprint class is a blueprint to construct the objects okay the solid I said class is a user-defined data now I am saying class is a blueprint here blueprint means what original copy blueprint means general copy to construct the Xerox copies Xerox means what instances now instances means what copies now the copies are nothing but objects that is why to create the objects we need the class that is why class is a blueprint and object is the instance of a class that is why another definition already you have discussed what object is a class variable now I am saying object is the instance of a class and another definition okay class okay here one small point is they already have given two explanations about object and the next expression is object is the physical representation of a class object is the physical representation of a as that means what okay here I said class is the blueprint means original copy and objects are the Xerox okay here the point is when the object is created then only memory allocated that means according to this example class never takes the memory means when class is created memory not allocated when objects are created then only memory allocated means a which requires the memory means an object that is why object is the physical and class is the logical okay it is a major point now it is nothing but what is a class what is an object of initiation I am going to cover the remaining move features thank you for watching [Music]
Info
Channel: Naresh i Technologies
Views: 261,168
Rating: 4.8870921 out of 5
Keywords: Kishore, Naresh IT, Hands on C++ Training, C++ Demo, Online C++ Training, C++ Tutorial Videos, C++ Overview, C++ Interview Questions
Id: 5Y74odV3IAI
Channel Id: undefined
Length: 26min 33sec (1593 seconds)
Published: Tue Jan 03 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.