 Welcome back, in the previous segment we talked about access control. In this segment we are going to talk about some classes that you have really been using and well maybe some which are slightly new but which you will want to use. So graphics classes, you may have guessed that our graphics primitives such as line, rectangle, circle are actually classes. So when we create lines, we are really just creating instances of the class or these are structs and we are creating structs. And when we write something like line L say 005570 this really is a constructor call. So in our graphics library there is a class called line or a struct called line and there is a constructor which takes 4 arguments and this is really a constructor call and that returns a line object or a line struct. So the constructor in this case is going to initialize an area of memory to hold information about object so which is what normal constructors do. They initialize the members but as we said earlier the constructors can contain arbitrary code as well. So in this case the constructor code is actually also going to draw the object on the screen. So important point that our line creation commands are really constructor calls to line a class called line and similarly for circles, rectangles, text. Now in the graphics classes there are data members which keep track of things like where is the graphic subject? What is the size? So what is the size? What is the color? And these members are private and therefore you do not get to see them. How do you change the color? You have been given a call so you can write L dot, you have been given a command of something but as you can see now this is just a member function. So you have been given member function, you have been given that control panel which enables you to change colors. So you do not have to directly go in and change colors. Those are the colors, there is some information kept about the colors but that is private information and you do not want to know that because that information is kind of complicated. So instead of that it is better to have the commands which is convenient for you to see and also graphics operations such as move and rotate are also member functions and how does your program get all of this? Well the header file simple cpp fetches or includes all the class definitions when you include that file in your program. Now like graphics classes there also are input output classes which you have been using. So c and c out are objects of class iStream and oStream respectively and they are defined in the file iOstream. If you remember we had a command c in dot get line of some buffer name, care buffer name and maybe the length of the care buffer name. So now you can see by the syntax that this is a member function. So you have been using member functions already in graphics as well as in iO. Now you may say that oh iOstream I did not explicitly include but we have said, we have discussed this earlier and we have told you that got included because you included simple cpp and less than less than and greater than greater than are actually operators and they have been defined for the objects by using things like operator greater than greater than. So that is what it is. iStream is another class like iStream and that is used for file iO. So you can create an object of a class iStream and associate it with a file on your computer. So once you do that you can read from that file pretty much like you read from cn and you can create an object of class and you can create an object of class oStream which can be used for writing files in exactly a similar manner and we will see an example next. But for this you have to include the header file fStream. So if you include that header file then you get to use iStream and oStream. So here is an example of file iO. So this is our program. So as you can see it is including fStream. It is also including simple cpp because of all the usual things that we have been talking about. So namespaces, namespace std and iostream and things like that. So what is new? So here is a definition. So we are defining an object in file and this is a constructor for it. Its type is iStream. So we are defining an iStream object. So what does this definition really do? So it says it really says the following. It says that in my program the name in file is going to be there. So that is the iStream. But while constructing it I am associating it with the file f1.txt which is going to be present in my directory. So that is what this line does. It is creating, it is a constructor call. So it is constructing a variable called inFile and its type is iStream. But the constructor is linking a file on your computer to this name inside your program. Similarly, oStream is a structure type and you are creating, this is a constructor call again. So you are creating a variable or an object, a name out file and type oStream and the constructor is associating the file name f2.txt with this out file. Now f2.txt is expected to be created when the program executes. It is an output file. So it need not be there early on. And here is the main program. So inside the main program what are we doing? We have a variable v of type int and we are reading an integer from inFile. So this operator works like before for cn. So if I had said cn I would have extracted, it would have extracted an integer from cn. Now it simply extracts an integer from inFile. So from this file in particular and this would have sent the value of v to cout had this been cout but now it is just going to send the value of v to out file. That is it. So this is how you can read files and write files and there are some additional details that you might want to know like maybe how do I append to a file and things like that. So that is discussed in the book but we are not going to discuss it in this lecture. So anyway so what does this program do? So this program is going to read 10 numbers from inFile and create a new file f2.txt and put those numbers inside that file. So this is of course trivial processing of files but now you get the idea. So you should be able to write programs which take data from files and which put data into files not only take data from the keyboard and put data onto the screen. So what have we discussed? We have discussed graphics classes, we have discussed input output classes and some of these things you have already been using but now you know that the commands that you are using involve classes and constructors and member functions. Next I am going to make some general remarks and then I will conclude this lecture but before that let us take a quick break.