Username:
Password:
C++ Fundamentals Tutorials

Basic Structure / Fundamental Types

Subtitles of the Movie

Hi there welcome back to our C Plus Plus programming fundamentals. We are talking about basic structures of basic structure, let me clarify that of the language in our fundamentals and we're going to take a look first of all at fundamental types in the C Plus Plus language. We won't spend a lot of time on these because we are going to see some of them in much more detail as we get into definitions and declaration and other parts of the language. But I just want you to know that they are there and this will be mostly a recap of things that you've already learned in C and other languages. We have Booleans, characters, integers, floating point variables, voids, enums, or enumerated variables, and then classes which create new types that we define on our own. We kind of list those at the end because its not really a fundamental type but you will be creating with enum and your own classes, you will be creating new types which will behave exactly the same as the bools, chars, int and all of the other fundamental types. So we at least want to mention that here. Now here's our first set of fundamentals and these called integral types, that's the Boolean character and integer types. Boolean is either true or false it's a one or zero, value if you want to look at it inside the machine and here we create a Boolean variable called var and then we set it equal to the result of A compared to B. That's our equality operator there, the double equals, if A is equal to B, and those are obviously previously defined variables, if A is equal to B, then a one or true value would be set into var and if they are not, then false or zero would be implemented initialized into var. Characters, we have the same character set up that we used to have in C and there are char, var, equal to a constant, quote A, quote for lowercase A and so on. They work exactly the ways they did in C and we also of course have unsigned characters. If you need them to hold a larger value. We have integers and again the same way we have short ints, we have long ints, we have normal ints and we have signed and unsigned of all of those. They default to signed so you don't have to use the word signed so they can hold less then zero values and you can use the keyword unsigned if you wanted to make unsigned integers which carry zero or positive values only. Its really only recommended to use unsigned integers if you want to create a byte field so that you can set and reset various bytes in the bit. It doesn't make any sense anymore to use unsigned to try to just hold larger numbers and normally type casting and shifting will mess you up anyway if your trying to have only positive values in something. You're going to get caught in type casting and its not going to do what you want to do. Here's our floating point fundamental types, float, double and long double, their initialized just the way they used to be. No big deal, one point, two, three, four, we can have floating point values in all of those. And now here is an interesting one, the enumerator or enum, now here we make a new type, this is going to be a brand new type, its going to be like an integer or character or you now one of the base types that's in the language. We use enum and here we're going to create something called a number word and number word will be equal to zero, one, or two, these values and that's exactly what it does. It assigns zero to the first a one to the next one, two to the next one, so these words will be in our case here they will happen to represent the numbers that are assigned to them. So here we make a new variable, it is of type number word, where you would put int or something like that we use our enum, its an enumerator type, we made a new type. Number word variable and we can set it equal to zero, we have to use one of the words that we, the identifiers up here that we use when we created the enum OK so we can set variable equal to zero and then we can test it based on that so we can say if this variable equals, again one of those words then we'll go and do something as a result of our if. So that's an enum. There are some other fundamental types, there's a void and a void is never used by itself because it isn't anything, it's the representation of nothing. So we can have void type pointers, we can have functions that are, that take void input which means no input, we have void return functions which are not allowed to provide any return and that basically tells the compiler nothing should ever be here, this is a void. But the word void is never used by itself. We still have pointers, and pointers are of the correct size in your computer to contain the address of something else. Alright that's going to be a pointer to another object or another item in the language of variable or a class or something like that. An array is a grouping of all the same things, a group of integers, a group of classes, we can have a array of classes, we can have an array of structures, all sorts of things like that. But it is a grouping of all the same thing. A reference we're going to see references in detail but it refers to another thing, another object without being that object. You never actually modify a reference, if you increment it you are actually incrementing the thing that it refers to. if you take an address of it, it doesn't exist in memory so it you get the address of what it points to as a reference. We'll see what those are and how to use them later. And then we have structures and classes, which are again fundamental types that we create when we create new classes and new data structures of other kinds of items put together. Other kinds of variables and other smaller fundamental types. So that's our fundamental types in our C Plus Plus fundamentals, so let's move on to the next video, thanks for watching.

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