Class Declaration in C++

Hi welcome to Naresh it this is Kishore and today we are going to discuss about the structure example in previous session I have discovered What are the differences between structure and C + + structured and later have given C plus plus structure and C plus plus class difference ok in previous session not discuss the differences between fee structure C plus plus structure and C plus plus structure and class today I am going to give an example on C plus plus structure according to the previous class structure is collection of heterogeneous variables that means iTel used to store different types of variables at one place not only that structure is a user defined because of user is able to select the required data types as per the program ok and structure allows to store both primitive and derived data types at one place structuralist to store the data in the form of records next structure allows to maintain the data in the form of object is everything is object oriented and to conduct the object oriented programming we are going to start the structure because of the total object oriented programming starts with the structure that’s why I am saying structures are the foundation for object oriented programming now in this class I am going to give one example on structure C plus plus structure ok now first of all I want explain what is the C plus plus structure Syntax ok now I am going to give Syntax of a c plus plus structure generally every structure should have to start with structure keyword every structure should have to start its structure word ok faster but it is a Keyword next every structure is having generally one name which is also called tagname ok every structure is having its diagonal! Here I am going to play square bracket general square bracket indicates official part 1st year tag name is not mandatory but it is required when the structure variables are declared in some other places know what is a structure variable later I will explain next now the structure started inside the structure generally we have to declare the variable normally every program contains variables now here also structure contains different types of variables which are technically called structural members which are technically called structural members I am going to give structure members generally variable declaration structure and function inside function declaration ok we can define the structure function function student id in which is going to which is equal to which at runtime without enter one ID number 1 it now there going to store in ID and name next year I want to print the date now that i d equal to hear it I want to print and tell us what next flight firstwall ID number is friend letter out I want to print the name also now close the function definition completed a function disclose this year i’m going to create the name because it is not first ID number is printed ok I did not work latest short name name is printed on the screen where going to get 1.1 Kishore both ok now printing also finish later object oriented programming language function function of the problem is the extension of C language ok hair extension of C language which is also called super set of C language ok or extended version of C language or increment of C language that’s why I C plus plus support all the features of C C plus plus support all the features of C language that means cplusplus hello to execute a C program with or without any modifications in cplusplus environment that means in C plus plus the class is not mandatory with the help of functions also we can conduct C plus plus programming but here the point is dost functions we are adding the classes and objects concept programming pointers c plus plus supports function oriented concept and object oriented concept that’s why I C plus plus is not pure object oriented programming language and Hotel the pure object oriented languages ok we’re having affair affair Java small talk ok now they are called pure object oriented programming languages ok affair Java SE next small talk I feel their called what they are pure object oriented programming languages C plus plus is not a pure object oriented programming language next now how to create a class and what are the components of a class and later how to create an object from a class first of all I am going to give you how to create a class with Syntax now I am going to start what is the class Syntax first class every class should have to start with every class should have to start with flash keyboard classes award and it denotes we are going to start 1000 likes every class have to maintain a name but here the point is ok class name is nothing but the structural tag name in C language when compared with A C programming in C language every structure is having a tag name structure tag name which is optional and here also in C plus plus the class name is optional maybe or may not now class and next space tag name next here visibility label or access specifier next month we have to start private or public or protected now here private Public Protected are called means which are called access specifiers class access specifier which are also called visibility labour and their indicating the scope of the variables are functions is generally data members and member functions now here the access specifier visibility level should have the end with: symbol next year data type Excel your calling mere one and Same data type variable semi call next here we can declare functions also that’s why here return type letter function and argument nexa selling concept now here bracket close; hair also cplusplus Class C plus plus in C plus plus class should be end with; every class should have to start with the class keyword and later we have to provide the tag name and later members actually Here they are called member ok and especially here variables they are called data members and here functions are called member functions next here what is access specifier or visibility level in C plus plus the main concept is what Data Hiding actually the Data Hiding is achieved with this private declaration ok C plus plus main concept is Data Hiding project difference between C programming and C plus plus is what C programming it is public that means we can declare the variable that any place and we can access from anywhere that’s why I see data is not protect because of it is public data provide that problem cplusplus is introduced with Data Hiding feature which is a concept of class and hin class the main advantages private declaration when the data members or private they can be accessed only with the member functions of share watch it return type function Excel you are calling function but in our cplusplus inside the class they are called member functions. Is we are going to declare both the variables and functions together into a single unit called class which is called the encapsulation fish is called encapsulation mechanism the sword encapsulation is the process of defining different variables means data member and functions means member functions into a single unit called class it is called ok encapsulation next another concept is what Data Hiding hiding refers to be what ok here watch it variable variable and functions now the point is data is available or this data is tied up with only the member functions that are declared inside the class 12 are declared as private bus I hear the main point when the data is private the should be accessed with the number functions of same class that means that not accessible from outside the class which is called Data Hiding that’s why only the class number means specially Member function can access the Private data it is called Data Hiding and this concept is achieved it private and here one more important of a private is optional ok here when there is no access specifier are ok access operator visibility level then the default visibility level is always private next another one public the numbers that are declared using public can be accessed with member functions and Outer functions also ok where the public members are accepted with member functions as well as other members also means outer functions also ok ok when the data is protected what happened this class can be accessible and its a derived class it immediately derived class can be accessible that’s why the protected members OK Here protected members are accessed only with what that class members and immediately derived class members that means there available minimum 22 classes but which is possible with only inheritance concept which is possible only with the inheritance concept The Silence what happened where create in one class from another class that’s why they call derived and it is called base class which are also called super and was derived classes now here also same concept hear the protected with superclasses when declared classes and immediately derived classes and further availability is depended on visibility mode inheritance mode next now I am going to give for small example on this class next one more thing here we have to remember the tag name is optional I said when it is optional means when the objects are defined here ok here in between closed brackets and; means curly brackets and; what is defined for example here object is there now when object is already defined there is no need of Tag name of class name Ok actually tag name is here nothing class declared then there is no need of objects object object then in other places of the program then you should have to go for class name otherwise class name is optional now I am going to demonstrate one example now I am going to study class just watch it for example class student no generally student is having what kind of data ID number every student is having ID number and every student is having a particular name suppose here I am going to declare private ok I have declared private later IND ID next year name of 20 next here in this area public void read student and why it shows student X bracket close; in this exam is the classname classmate next private and public which are called access specifier Asha also called visibility levels ok access specifiers or which are also family with visibility because of their indicating the indicating the visibility of data inside the class outside the class that’s why they are called just before you discuss. Private it is not visible outside the class when data is public it is visible outside the class that’s why I hear their indicating the availability or visibility of debtors are called access specifiers or visibility plan next IND ID and name generally we are calling wherever but when they are inside the class there are called data member now this data already know that should be accessed with functions of same class only because it is not visible outside private private ok the class is used S Class I like that that’s why it is mandatory declared at least one Member function in public area why because only the public members are visible outside and here we are going to declare this class objects in main generally the amendments it is out of the class 1 data is private what happens when all the members are private they are not visible in a main function then we are not able to access this Private data that’s why one function should have to maintain public otherwise they have declared friend function otherwise you have to declare the friend functions does it have this problem it is better to declare Member function in public area of these functions are called member functions nowadays the class construction extra class class name and data members member functions and along with access specifiers or visibility levels next hear what they are called member functions and everybody knows and here everybody knows that generally function consists of three parts one is what function declaration one is function calling another one is function definition here function declaration which is also called function prototype now here it is the function declaration part and we need the function definition and function calling how to define simplest ways we can define a function into which one is inside the class and other one is outside the class ok one is inside the class 11 outside and inside the class what happens and when it is outside class what happens means when it is defined inside it will be come in line member remember this year member function is defined inside the class now that number function will become inline Member function ok next planet is outside it is not in line number house when it is inline function program performances increased and when it is outside program performance not recognised and when it is inside we are not able to make it is a rule there is a role what is the role means and we are not able to write Complex statements because of warning sarees that’s why in C plus plus it is better to write the functions outside the class and what is the syntax to define a function outside the class in next station we are going to discuss how to define member functions Ok actually in this class I have given how to create a class how to define a class next generation I’m going to cover how to define member functions and how to define a object thank you for watching

Speak Your Mind

*