 the NPTEL course on an introduction to programming through C++. I am Abhiram Ranade and in this lecture I will continue to talk about structures. So some reflections on what we have seen so far. So we propose that all attributes of each entity in our program should be grouped into a structure. And we said that the benefits for this are that it would reduce the clutter overall. It will make it easy to pass the entity to a function. We can pass it as a single argument rather than all the different variables which are associated. And because we have fewer arguments, we will be more likely to write lots of functions. And also each function will have its concern very limited and therefore understanding what is going on in the function and reasoning about it in general will be easier to do. Well now here is an observation about how such entities are processed. So typically there may be many attributes that an entity might have but they are accessed in only a few different ways. So I am going to take two examples. One is a vector from physics and another is the Q that we had in the taxi dispatch problem that we saw earlier. So in both these cases the vector and the Q will have many attributes or many members. But you will note that usually we do not read or update the individual members in isolation. A natural operation requires us to simultaneously access or update several attributes and in a very specific manner. So what does it mean? So it means really that we should support this kind of access and update rather than the update involving individual members. So let me show you these examples a little bit more in more detail. So vectors from physics. So in physics vectors are used to represent lots of things, velocities, positions, displacements, and fields and say if it is a vector in three dimensions then it can be indicated by its components in the x, y, z directions. So maybe we might have a vector type V3 and it can contains members x, y and z. There could be other representations as well I mean there could be the polar representation for example or the cylindrical coordinate representation. So here is a key observation. So for this representation you will rarely read just the x component or rarely update just the y component. What you will typically do is will involve something with will involve all three coordinates. So maybe we will add two vectors together or maybe we will scale up a vector. So both these operations will involve changing all the coordinates and that change will happen in a very specific manner. The taxi dispatch problem we saw earlier and it is discussed in chapter 14 of the book. So briefly we have customers arriving and how to be assigned to waiting taxis. An important part of that solution was a queue and into this queue we put the IDs of the waiting taxis or rather the IDs of the waiting drivers. And the main part of the queue was an array and these elements were the ones in which we stored the IDs. And then there was a variable n waiting indicating how many drivers were waiting and a variable front which indicated the position of the first waiting driver. And again we can make the observation that the queue was accessed using operations insert, remove and initially we had to set n waiting equal to front equal to 0. We did not arbitrarily examine the elements of the array or change in waiting or front in isolation. So whenever we made the change there was some high level operation that we had in mind and our code was implementing that high level operation. So the insight from all of this is that first of all we should put all the attributes of an entity into a structure. But in addition we should provide functions with which to access the attributes. And these member functions, these functions are customarily member functions or the functionality that we want for accessing is provided by something called member functions. And these member functions are the main topic of this lecture. So to put it differently we should avoid accessing attributes directly, why is that well very likely this indicates that we are doing an operation that has not been clearly thought through and therefore maybe it contains errors. So clearly something real or even abstract but sort of something that we clearly know if something that we clearly understand like a Q or a vector has its own logic and that logic has to be incorporated into functions and we are going to describe this notion of member functions which is going to be most useful for incorporating such logic. So we must think about and catalogue the right ways of accessing an entity. So here is the outline of this lecture, we are going to have a bit more discussion on the vectors from physics then we will introduce this notion of member functions. And I should mention here that member functions were not present in C, they are an extension to what we inherited from C and the extension is proposed and implemented in C++. So this is kind of a more modern feature if you will. After discussing member functions we will talk about taxidispatch and see how that as well can be written using member functions. So what did we discuss in this part of the lecture? So we said that it is not enough to just define a struct to hold entities. Usually we will also want functions which work on these structs. In C++ you can make the functions a part of the struct definition itself and such functions are called member functions. In some ways member functions are similar to control panels found on the front of appliances. So you are expected to operate an appliance through the buttons or other controls that have been specifically provided. You are not expected to innovate or you are not expected to do tricky things when you operate an appliance. Say for example you are not expected to open the back and change some capacitors or change some wiring. So if you want to change the channel on a television there is a very, very clear, clear way to do that and analogously the thought is that member functions indicate to you what is sort of the clear proper way of doing things. And in some sense you do not want users to go looking into the data members themselves and changing the data members because they might be making mistakes in doing that. So next we are going to develop this idea and for that we are going to look at vectors from physics. But let us take a quick break.