Classes / Class Objects
Subtitles of the Movie
In the next few videos we're going to be talking about class objects or classes and the definition of classes and how they are used to create objects and I think we talked a little bit about it before that C also had objects but that was anything that you could create in C, that was a variable, anything at all, an integer, a character, any of those things were considered to be objects. Well we use the term a little differently now and we are talking about object oriented programming, and getting into more detail, an object is when we instantiate a class and a class is just a description of what a object will eventually look like should we decide to make one. Now all this object orientated business, that's called a modular programming method, but C Plus Plus will support both procedural and modular methods. It does however make it easier for you as a programmer to implement and use modular methods. Though I want you to know that everything you learned in C, in C programming still does apply. But there's more, C Plus Plus supports and encourages modular methods, again it makes them easier for you to implement so that you can use these modular methods without going out of your way. Actually the compiler will enforce some of these things for you if you let it. There are switches and things that you can set on a compiler to make it not check these types and do various cast checking and things like that but you don't want to do that. I mean that defeats the purpose, that's only if you need to code something in something using a C Plus Plus compiler. So here in the procedural world you would decide which procedures you want and then get the best algorithms that you can find and that's normally what we have been doing for many, many years in programming. You would decide top down, step one, step two, step three what do I need to do to perform a particular task and that's a procedure, you have process you go through or procedure one thing after the other. And that's essentially what we've been doing all these years and we tell the computer what to do first and second and third and so on. Now object orientated though, that's a whole different way of thinking, in object orientated we decide which modules we want, we have to think of them as kind of different containers, almost black boxes that do whatever they are going to do. And then we partition the program into these modules so that the data that's necessary to be used by a modular or an object is hidden inside that module, very little information is really going to be available to the outside world. This is a whole new way of thinking and this is the object orientated programming paradigm that they call it and this allows objects to interact like they would in the real world if you have two cars on the road they interact in certain ways. They don't interact by their pistons connected to one another or carburetors or fuel injection or any of those internal things. They connect to one another by turn signals which are of course controlled by the driver, the operator of the thing. So those are external or public bits of information about the object or in our case about the car that are shown to the world and known to the world, made public, other private things, the world doesn't need to know about, but the vehicle itself, the car itself or the operator of the car need sto know a little bit more. So these objects will be self contained objects and will only interact with each other in very specific ways. When we have a class object, when we have a class created the class will contain both the data inside the class, the members they call it and the functions which are known as methods that will work on that data. Now we saw something very similar to this when we had structures back in C, our struct, a struct with functions in it is very much a class. That's a class definition. We have some new things though, we can make some methods public and some methods private and there's even a protected method in data and we'll, we are going to talk about all these as we go but public methods are like I said like the turn signals, things you can see from the outside, private methods would be only usable by other methods within the class. Some data variables, certain things about the object are available to the public to be read, even to be set and changed and some of those data are private as well where we only want the class to be able to deal with those variables. Obviously as we get through this as we look at data members and member functions and methods and all of that sort of thing coming up we're going get involved in some detail. But you need to really start to thinking about this, that object orientated programming, you are going to be creating self contained modules, those classes will be able to communicate with one another through specifically defined methods and public members of data an those are called interfaces, when one class can communicate with another or a class allows itself to be manipulated in some way, that's through an interface and we will show that we can have multiple interfaces to a single class. So that's going to be kind of interesting. Hang on for the ride its going to be a good one and we are moving right along to the next video.
Tutorial Information
| Course: | C++ Fundamentals |
| Author: | Tim Heagarty |
| SKU: | 33797 |
| ISBN: | 1-934743-09-7 |
| Release Date: | 2007-09-14 |
| Duration: | 4 hrs / 55 lessons |
| Captions: | For Online University members only |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 