 Hello everyone, myself, Shweta Sadaw, currently working as Assistant Professor in Department of Computer Engineering of K. Kivak Institute of Engineering Education and Research, NASA. Tim Jobs once said that everyone in this country should learn how to program because it teaches you how to think. If you are searching for a course which will help you to understand the basics of programming language and guide you to write the program, then the course Learn Basics of C++ Programming is the right choice. There are hundreds of programming languages in the market, but when it comes to the performance, C++ Programming is the best. Big companies like Google, Facebook, YouTube, they are relying on this language that is C++. These are the contents that we are going to see in this course. Introduction to C++, Structure of the C++ Program, Classes and Object, Instructor and Disruptor. I will request you to enroll for this course and after completing, please provide your valuable feedback. Thank you. We are going to study Introduction to the C++. Along with that, we are going to see what are the different features of the object oriented programming language C++, why there is a need of using the object oriented programming language that is C++, what are the different compilers and which are the applications. Let us begin with the introduction to the C++. In this, we are going to see who invented the C++ language and what was the earlier name of the C++ language. C++ is an object oriented programming language. It was then developed by Barges Tostru at E.T. and T. Bell Laboratories in Morehill, New Jersey, USA in the early 1980s. C++ is an extension of the C with a major addition of the classes. The idea of the C++, it came from the C increment operator that is C++. Thereby, it suggested that C++ is an augmented version of the C that is also called as the superset of the C. Tostru initially called the new language C with the classes, however in 1983 the name was changed to C++. What is the need of the object oriented programming? As there were many flaws in the procedure oriented programming, so the new approach was developed that is object oriented programming. Flaws of attempts were made to overcome the flaws of the procedure programming. The major things that was missing in the procedure oriented programming that it emphasis on the procedure and the functions, while in case of the object oriented programming the major focus was not on the functions, but it was on the data. The object oriented programming, it treats the data as the critical element and not the functions. This is the another important aspect that it does not allow the data to flow freely around the system as in the procedure oriented programming the data was being kept global. So any function can access the data which may cause unintentional changes which allow the books to creep. To avoid the restrictions were kept in the object oriented programming on the data. In object oriented programming the data is closely attached to the functions which operate on it, so both of them are considered as one unit. In major cases they are considered. It allows to compose a problem into the number of the entities which are called as objects and then builds the data and the functions around this objects that we create. It is necessary to understand the features of the object oriented programming in the C++. What are classes? Classes are the blueprint for the functional entity which will be defining its properties and the functions. And what is the object? Object are the basic runtime entities in an object oriented systems which has the state and the behavior. It is an instance of the class. All the members of the class are being accessed through the objects. Abstraction. It refers to the items of representing only the essential features without including the background details. So let us understand this with the help of the example. Whenever we are using any of the application at that time we are only see its printing that is we are only using that application we are performing it what actually it is being used for but we are not knowing what is there at the backing what actually it is being performing which language is being used so that information is being hidden from us. Encapsulation. The wrapping up of the data and the functions into a single unit. Data encapsulation it is one of the striking features of the class inheritance and this objects of the one class it is acquiring the properties of the objects of the another class. This provides the code reusability polymorphism the ability to take more than one form when one task is performed by the different ways. Let us consider the example if we want to perform the addition of the two numbers at that time we require the plus operator then what result we get we get the result as the sum but if we use the same operator that is the plus in the string then it will produce a result as concatenation of the two strings. The next feature is dynamic binding it means that the code associated with a given procedure call is not known until the time of the call at the runtime. Message passing object oriented programming it consists of the sets of the objects that can communicate with each other object oriented programming it uses the bottom up approach. Which are the compilers that C++ uses so here is the list that is Microsoft Visual C++ Eclipse Codeblocks, Dale C++, Nate Bains, IDE, CYGWIN, GCC. There are some now online compilers that are too available to compile the program. Let us see the applications where the C++ language is being used it is being used in the games to develop the GUI based applications in the database software and in the operating systems there are many more applications many more applications in this lecture we are going to study the structure of the C++ program and the structure of the C++ program. A sequence of the instructions or the statements are called as the program. The statements or the instructions they form the structure of the C++ program. The C++ program structure is divided into various sections namely header class definition member function definition and the main function the first section that is include. In this it contains the pre-processor directives to include the various header files. After this there is a class declaration section in a class declaration we are defining the class it will contain the member variables and the declaration for the member function. The class member function definition section that is going to contain the definitions of the various member function. At the last there is a main function program which starts the execution of the program and then it is going to create the object of the class. Note that C++ program it is providing the flexibility for writing a program with or without the classes and its member function definition. Let us begin with a simple example of a C++ program that prints a string on the screen. I am using a visual studio to execute the C++ program. To compile a program we need to create a project and give the name. Here I am giving the name as hello world and dot cpp it is an extension which is indicating that we are writing a C++ program. The reader must understand which program we are writing so the heading will be given under the comment sections. There are two way to write the comments. First is single line comment and the second is the multi-line comments. The comments are being given for the reader they are not given for the compiler. For this we are using the single line comment and then we will write the statement as write a C++ program to display hello world. The next important part is the pre-processor directive. Thus we have seen in the lecture structure of the C++. We are generally included at the start of the program. How we are writing it so this is the syntax that is hash include IO string. It contains the standard input and output strings. This header file contains the definition to the objects like C in and C out. The next we will be writing it as using namespace STD. The namespace it defines the scope for the identifier that are being used in a program for using the identifier defined in the namespace scope we must include the using directive. Here the STD in the namespace where C++ standard class libraries are defined using and the namespace are the keywords in the C++. After this we will be writing the main function. Before writing the main function the data type is to be defined. The data type that we are going to write is the integer. As we are writing the integer data type it is going to return some value. What value it is going to return? So it is going to return the value in the form of 0. Then now what we have to do we have to display the hello world onto the console. So for that we will be using the C out then the insertion operator in double inverted commas we will be writing the hello world. But before that if we want to insert it onto the new line then we will be writing it with the help of slash n. Then we will be writing it as slash t. Why we are using this slash t? Because we want to give the tab and then we want to display hello world. After writing the statement we are going to terminate it with the help of the semicolon. If we don't terminate it with the help of the semicolon it is going to throw an error. Let us build this program. Here is the output that we are getting. Let us understand what is this output indicates. Slash n here we have getting this as the empty line or the new line. Onto the new line the output is being displayed then the slash t. Here the tab is being left then the hello world. So after this hello world if I want to insert the new empty line then what we will be writing there is another way to write the slash n. That is nothing but the end L. With the help of this we will be inserting the new line. So hope so you have understood how to display the hello world onto the console. In this lecture we will be seeing the classes and objects. In that we are going to see what is a class, objects and how to access the data members and the member functions. What is a class? It is a user defined data type. A class is a blueprint for any functional entity which define its properties and its functions. It encapsulates the information and behavior about an object. A class contains the data members or the attributes. A class is an expanded concept of the structure. Instead of holding only the data it can hold both the data and the functions. Let us see the syntax of how to declare the class. This is the syntax of declaring the class. The class definition always begins with the keyword class followed by the class name. The class body contains the variables and the functions. They are called as the class member. The variables declared inside the class are called as the data members and functions are called as the member functions. The access specifier is a keyword in object oriented programming language which sets the accessibility of the classes, methods and other members. Access specifiers are grouped under the section private, public or the protected. They are mainly used to denote which members are private or the public. And here we are going to terminate the class with the help of the semicolon. Let us see the example of how to declare the class. Here is a example, the class keyword followed by the class name student. This will now become a type identifier that can be used to declare the instance of the class. The class contains the two data members and the member functions. Remember that data members are private by default while the member functions are public by default. The function get data is used to assign the values to the member variables and the void show is used to display the values. And then we are going to terminate the class with the help of this semicolon objects. Now we have created the class once it is declared we need to create the variable of the type. An object is an instance of a class. Object are the basic runtime entities in an object oriented system which has the state and the behavior. All the members of the class are accessed through the objects. Let us see the syntax class, class name and the variable name accessing the data members and the member functions. You can access the data members and the member functions by using the dot operator. If the data member is declared as the public, let us see the syntax. Here is the syntax which is showing that object name. Then we are going to use the dot operator over here, followed by the function name. In the rounded brackets, we are going to pass the actual parameters. Let us see the example. Here is the example that is the student dot put data. This will display the values of the data members. A member function can only be invoked by the object of the same class. The data members can be accessed as student dot age is equal to 25. We have to take a note that private data of a class can be accessed only through the member functions of a class. In this lecture, we are going to see the access specifier. What are the different types of the access specifiers and how to use the data members which are being declared with the different access specifiers with the help of the examples. In this lecture, we will be studying the access specifier for the C++ classes with the help of the example. As in the last lecture of classes and object, we have seen access specifiers are being used before the declaration of the data members and the member functions. Why this access specifiers are being used? Because they are used to enforce the restriction to the members of the class. There are three types of the access specifier. The first is private, second public, and last is the protected. Let us see one by one in detail. The first access specifier that we are going to see is the private. It makes any member accessible only to the member functions of the class. This is restricting to use of the class members within the class. It may be applied to the data member and the member functions. The data members are normally declared as the private. This encourages the information hiding. Let us write a C++ program to demonstrate the private access modifier. In this, we will first try to access the private data member directly with the help of the dot operator and check what output we are getting. First, we need to declare the preprocessor directive that is hash include iostream. Then using name, space, sd, class, class name, student. Within this, the first data member that I am going to declare it as a private, int, roll number. Then member function void, put data. This function is going to display the roll number. C out, flash in, roll number, variable name, roll number, and l. Now write the main function. This int, main, within this, create the object first of the class student. That is, student student see out statement to ask the user to enter the roll number. Here I am trying to access the private data member roll number with the help of the dot operator student dot roll number. Then invoke the put data function with the help of dot operator student dot put data. Finally, return some value that is zero. Build the program and see what is the output. There were built errors. Will you like to continue and run the last successful build? We will say no and see what is the error. Here the error it is showing that it cannot access the private member declared in a class student. Now to access the private data member, what changes we have to perform in this program? Let us do the modification. Over here, I will in the put data function, I will indirectly manipulate this roll number through the public function. Since this function it has been initialized to roll number with the value of the argument that will be passed in the put data function as int, r. Then the value that is being there in the variable r, it will be assigned to the roll number. In the main, I will be declaring one variable which will be indirectly accessing the roll number. For that, I will change over here also, here roll and as the parameter is being passed in the put data function. We need to write it over here when invoking the function 2. For that, I will write over here as the roll. Let us build the program and see whether now we are getting the output. As there are now no errors, the program is being built successfully and it is now asking us to enter the roll number. I am now going to enter the roll number as 5 and it is being displayed correctly. So this is how we are going to access the private data members indirectly with the help of the public function. The next access specify that we are going to see is the public. Public members may be accessed by the member functions of the same class and the functions outside the scope of the class. Which means that the public members are accessible from any part of the program. The member functions are normally declared as the public. This means if we forgot to declare the access specify for the member functions, at that time the member functions will be considered by default as the public. Now, write a program to demonstrate the public access modify. We already know that the data members or the member functions that are being declared as public. We are directly able to access it with the help of the dot operator. Let us see its demonstration first. Hashtag include IO string. This is the pre-processor directive or it is also called as the header file. Then we will be writing using name, space, sd, class, its class name within this first write the access specify. Then the data member int rule number member function as put data. In this function I will be writing the see out statement to display the rule number. In the main function we need to create the object of the class student. Object name as stood. See out statement to ask the user to enter the rule number. Here I will be accessing the data member rule number directly with the help of the dot operator stood dot rule number. Now invoke the put data function with the help of dot operator stood dot put data finally written zero. Let us build the program and see the output. Here it is asking us to enter the rule number. I have entered the rule number as it. The value it is being displayed over here as eight rule number eight. To access the rule number that is being declared as public we have used the dot operator directly. And the last access specify is the protected. This protected access specify is between the private and the public access. If the member function is being declared in a class as protected at that time they cannot be accessed from outside the class. But if we want to access it, it can be accessed from the derived class. So in this case the member of the base class can be used only within the derived class as the protected members except for the private members. In the last lecture we have seen how to create the objects. In this lecture we will be studying how to create the array of the object. An object of the class it represents the single record in the memory. What happens if we want to have more than one record of a class type? At that time we have to create the array of the objects. As an array it can be of any data type. We can also have the array of the variables that are of the type class. Such variables are called as the array of objects. Let us see the example. Here the class is being created for the student. Within the class body I have declared one data member as the student name. It has been declared with the help of the data type that is the character. Next data type is the roll number which is of the integer data type. Then the access specifier public and the member function gate data and the put data. Then we are going to close the class with the help of the semicolon. What happens if we need 80 students data? Then at that time we are not declaring the different objects. That is student 1, student 2, student 3 up to student 80. Why? Because it will become very difficult task to handle. For this we need to use the array of the objects. Write a C++ program to accept the student's data and display. For that we need to first write the header file. That is hash include iostream using namespace strd. Declare a class class keyword followed by the class name. The class name it is student. Within this we are going to declare the data members and the member functions with the help of access specifier. The data members that I am going to declare in this program are private. We will be accepting the student's information such as roll number and name. Roll number it will be in the form of the integer format. For that we will be using the data type as the int followed by the variable name that is roll number. And for the name we will be using the data type that is the string and the variable name as the name. After declaring the data members we need to declare the member functions. The member function that I am going to write is the void gate data. In this the first message that will be displayed onto the console is cout. Then the insertion operator in the double inverted comma slash n slash n it indicates that it is going to go to the new line. And it will be displaying the message enter the roll number. After that we need to accept the input. For that we will be using the CN then the extraction operator and the variable name. Similarly for the name we are going to write enter the name CN name. After accepting the student information we need to display it. For that the function we will write it as the void for data. Into this we will be using the cout statement. Roll number the variable name and the end L. This end L it will be acting similar to that of the flashing. Now what we have done we have created the class. We need to now write the main function. The main function we are going to write it with the help of the data type that is the integer. In the main function we are now going to create the area of object. For that we need to write first the class name and the object name. The object name I have given over here is as the stood and the array size we have to specify. The array size that I have given over here is as the two. As we are using the array of the object concept for that we will be using the for loop. With the help of this for loop we will be able to accept the multiple students data. In this for loop it will be divided into the three parts which are the first we need to initialize the array. The initialization is being done first to zero. Next we need to specify for how many times this loop it is going to iterate. As the maximum size is being given as two. So over here I will be writing i is less than two which indicates that this loop it is going to iterate it for the two times. How it will iterate for that I will be using this i++ operator. Within this for loop the first statement that I am going to write it in the double inverted comma that is detail of today. After this I will be writing i plus one. Why I have written over here as the i plus one because i value it is being initialized to zero. We don't want to display detail of the student zero. We need to display detail of the student one for that I have added plus one to i. After this statement we need to invoke the gate data function for that we will be writing it like this. Then dot operator and the function name that is gate data. What it is going to do first it will accept the first information of the student. Then it is going to iterate it for one more time to accept the seconds information of the student. As we have accepted the two students information we need to display that two students information. Again we will be writing the for loop and i is equal to zero. i is less than two i++. Within this the C out statement student i plus one and nl. Then it is going to invoke the put data function. Then it is going to return the value in the form of the zero. Let us build the program and see what output we are getting. As there were no errors in the program the program is being built successfully. And it is being showing us on to the console to enter the student information that is detail of the student one. Then we are going to enter the roll number of the first student then the name as the rushing. Then it is asking us to enter the second information of the student. So the roll number as five then the name as a rummage. See as we have accepted the two students information were here that two student information are being displayed. This is how we will be using the array of the object concept to accept the multiple details. In this lecture we are going to see the friend function. Why do we need a friend function in the access specify we have seen that we are not directly able to access the private and the protected data members. To access that we need to use the friend function. A friend function in a class can access the protected and private class members. That is it can access the private data members and the member functions. To use the friend function in a class what we have to do we have to mention the keyword friend before the function name. For accessing the data the declaration of the friend function should be made inside the body of the class starting with the keyword friend. Let us see the sentence. Let us understand the syntax of declaring the friend function. Here what we have done we have created the class with the class name. Within this we need to declare the friend function for that the syntax is like this. First we need to write the keyword friend then the written type then the function name and the arguments. What arguments we are going to specify over here so it will be the object of the class. The definition of the friend function will be written outside the class for that there is no need to declare the friend keyword again directly. We will be mentioning the written type function name and the arguments. Within this we will be able to access the private and the protected data because it is a friend function of a class name. Now the question may arise how we will be invoking this friend function so it can be invoked like the normal functions without the help of any object. Write a C++ program to accept the student data and display it using the friend function. Let us understand this concept by writing a program and what output we will be getting. That is we will be writing first the header file that is hash include IO string. Next we need to write using namespace std. Here we need to declare a class now for the class the class name that I am going to give it as a student within this we will be declaring the data members as a private. The first variable is int roll number the next is string name then I will be declaring the member function. First member function is void gate data with this function we will be able to enter the student data. That is with the help of seen and the see out statement enter roll number see in roll number see out flashing enter the name see in the name. Next here I will be using the friend function to display the data what is the syntax let us check it first friend as keyword then the data type that is void the function name that I am going to give is the put data within this I will be passing the arguments. What type of argument here we will be creating the argument as the object so student is the class name and the object name is s in the class we have only declared the friend function. Definition I am going to write it outside the class how we will be writing it for that we will write void put data then the object student s within this I will be writing the see out statement which will be displaying the data that is roll number. We need to now access the private data members for that we will be accessing it with the help of the object s dot roll number the next see out statement is to display the name then over here s dot name. After this we will be writing the main function within this main function we will now create the object student the object name that I am going to give is the student with the help of this object I will be now invoking the get data function with help of this statement the get data function will be invoked. Now the next thing how we will be invoking this put data function for that I have already told you we are not going to need the object for that we will be directly invoking it as the normal function we will write it as put data over here we will pass the object. Finally it is going to return some value in the form of the zero this is how the friend function is declared in the program. Let us build the program and see what output we are getting see after compilation it is being asking the user to enter the roll number here I will enter the roll number as 10 then the name. The name I am going to enter it as the Ramesh see the output the values that we have entered it is being displayed. This is how we are able to access the private data members or the private member functions with the help of the friend function. In this lecture we are going to see what is the constructor different types of the constructor and at the end we are going to execute the program which will be containing the different types of the constructor. What is a constructor it is a special member function which can initialize the object of the class. It is special because it is having the same name as the class and no written type not the void also member variables can be initialized by the constructor or they can be set afterwards. The constructor get invokes when the object of the class is being created. Let us see the example of the constructor here what we have done we have created the class student within this the two data members that are being declared as the private. Then in a public what we are going to do we are going to define the constructor. Here we can see that the constructor is having the same name as the class as already we have seen it on to the last slide that the constructor is not having the written type. Not even the void two types of the constructor. There are three types of the constructor which are they default constructor parameterize constructor and lastly the copy constructor. Let us see one by one constructor in detail that we are going to see is the default constructor as the name indicates that it is a default. The default constructor is not going to have any arguments. It is used to initialize an object of the class with the legal initial values which can be initialize to zero also. Here is the example of the default constructor what we have done we have created the class student then the data members which are being declared as the private in the public. The constructor is being declared to that the initial values the data members were here they are being initialized to zeros. Now this is being called as the default constructor parameterize constructor as the word indicates that parameterize it is going to accept the arguments. It is going to initialize the data members of the object with the arguments that are being passed to it here is the example of the parameterize constructor. The data members are being declared under the private and the constructor is being created which type of the constructor that is the parameterize constructor and three different parameters are being passed. Here the variable r it is going to assign the value to the data member roll number. Next the string n this n variable it is going to assign the value to the name and m it is going to assign the value to the marks. The last constructor that we are going to see is a copy constructor. The copy constructor is going to take an object as an argument and the values they are going to copy from one data member of one object into the another object. The reference variable it is being used as an argument to the copy constructor. Here is the example where we can see how to use the copy constructor. What we have done we have created the copy constructor. Then within the copy constructor the syntax that is being written that is the class name the reference variable is being given and the object is being created. With the help of this object the data is being copied it into the roll number. Write a C++ program using the constructor to display the student data. In this we are going to use the three constructors that is default parameterize and the copy constructor. Let's start writing with the program for that we will be requiring the preprocessor directive that is ioStream. Then using namespace std class class name within this we will be declaring the data members as private. Integer, roll number, ring, name and the float marks. The next we are going to declare the constructor. The constructor are always declared as in the public. The first constructor that I am going to declare it as the default constructor. The constructor is having the same name as the class. What is the class name? It is having the class name as student. For here we are writing the default constructor name also as the student. To understand we will be writing it over here with the help of the command as default constructor. Within the default constructor we are now going to initialize the values to zero. Roll number as three and sorry roll number as zero and marks is equal to it is in the integer format. So we will be writing it as 0.0. Next what we are going to do we are going to declare the parameterize constructor student. Then the arguments we need to pass over here. How many arguments we will be requiring? We will be requiring the three arguments. The first argument is the int r then the string n and float m. Which type of constructor it is? It is parameterized constructor. Within this what we are going to do the arguments that are being passed over here the values will be assigned to the data members that are being declared under this. It will be roll number is equal to r name is equal to n marks is equal to m. The next constructor we need to define it is the copy constructor. Who we will be writing it for that it will be student within the rounded bracket we will be writing it as student. Then the reference variable and the object we are going to create which type of constructor it is it is a copy constructor. Then what we are going to do we are going to write it like this that is roll number is equal to s dot that is object dot the variable that is roll number. Next the name is equal to s dot name. Next marks is equal to s dot marks. This is how the copy constructor is being written. Now the next that is the data is being how the data is to be written that part we have written now how to display the data for that we have to write it like this. Within this we will be writing the cout statement roll number then variable name and n. The next cout statement is for name and n. Next cout statement is for marks. After this we need to declare the main function it mean in this we will be creating the objects. The first object that I am going to create is for invoking the copy the default constructor. Next is for the parameterize constructor. Here the parameter that I am going to pass as one then the name and the marks. Then the next is for the home it is for the copy constructor over here. What parameter will be passed we are going to pass the object that is being created earlier whose data we want to copy. We want to copy the data from the object to two. Over here now we will be accessing or invoking the display function to two dot display to three dot display. And finally it is going to return the value in the form of the zero. Let us build the program and see what output we are getting. As there were no errors it into the program the program is being built successfully. Over here the first output that we are seeing it as roll number is equal to zero and marks is equal to zero. Why because over here we have been initialize that values to zero. The next over here the second values that we are seeing it as roll number one name as rummation marks is equal to 80.5. Why because this data is being given with the help of the parameterize constructor. And the third values that we are getting because of the copy constructor. This is how the constructors are being used within the program. In the last lecture we have seen what is a constructor what are the different types of the constructor. Now we need to see the disruptor. It is a member function of a class. The name is still it is being followed by the class name. Why we are using this destructor because we need to destroy the objects that have been created by the constructor. That's why we use the destructor within a program. It receives no parameters and it is not going to return any value. This is the important thing that we have to remember while mentioning the destructor within the program that there is only one destructor per class. No overloading is being allowed. In the last lecture what we have done we have created the constructors. The same program we are going to consider and we are going to destroy the constructors one by one. For that what we have to mention it within the program. First thing that we have to use the tail operator then the class name within the curly bracket the see out statement that I am going to write it as destructor. Understand we will write it over here as destructor. Let us build the program and see what is the output. This is the output that we are getting how many constructors we have created we have created this three constructor default parameterize and the copy constructor. Now we need to destroy that three constructor. So over here it has been displaying the statement for the three times. Next you might get a thought that why we have written only one destructor over here because in a program there will be only one destructor that we have to mention. So thank you.