Overview of data types

- C++ is strongly typed language.This means that every value has a specific type.The meaning of a value is determined by its type.A data type determines both the sizeand the interpretation of a value.For example, the int type means a natural machinesize signed integer value.And unsigned int means the same size integerwith no bit reserved for sign.Fundamental types for C++ includeinteger types for representing integer numerical values,floating point types for representing real numerical values,and a Boolean type for representing true and false values.

C++ also provides literal values for true and false.An array is a contiguous sequentialset of objects of the same type.Arrays are very powerful, flexible,and have very low overhead.They're also the basis of C stringsand the C++ SDL container classes.Athough C++ has no fundamental string type,a null terminated array of charactersis a special case called a C string,and it is treated as a string in many contexts.

A structure is a sequential set of objects of various types.A structure may contain scalers, arrays,and even other structures and classes.C++ classes are based on structures.Technically, a class is a structurethat defaults to private membership.In practice, a class is a structurethat contains function membersas well as data members.A union is a set of overlapping object types.This allows a single compound objectto hold objects of different types,at different times, overlapping the same space.

A pointer is a reference to an object of a given type.A pointer itself typically holds the addressof the object it points to.Pointers are strongly typed in C++.The type of a pointer is usedas the type when it's de-referenced,and is also used to determine the sizeof increments, decrements,and arithmetic operations on the pointer.A reference is like a pointer, but with different semantics.The major distinctions between pointers and referencesare that references are immutable,and once defined they cannot be changedto refer to a different object.

References are accessed as aliaseswithout any syntactic indication that it's a reference,and not directly a variable.This allows for silent side effects.C++ provides a number of fundamental data typesthat may be used or extended for many purposes.The rest of this chapter will coverthese types in greater detail.

Resume Transcript Auto-Scroll

Author

Released

12/16/2014

C++ is a workhorse. Widely used for both systems and applications development, C++ is available for virtually every operating system and has influenced and informed many derivative languages, including C# and Java. In this course, Bill Weinman guides you through the nuts and bolts of this essential language. He starts with the basics—syntax, operators, loops, and functions—and moves on to data structures, objects, and templates. He explains inheritance and operator overloads, and dives into the powerful container classes in the Standard Template Library (STL). These exhaustive C++ tutorials will provide a solid reference for both experienced programmers and those who are brand-new to the language.

Topics include:

What is C++?

Anatomy of a C++ program

Writing statements and expressions

Declaring variables

Using loops

Defining functions

Getting the most out of the preprocessor

Creating classes and objects

Undertanding data types

Overloading operators

Understanding inheritance

C++ template programming and the STL

Handling exceptions

Skill Level Intermediate

7h 48m

Duration

2,177,677

Views

Show MoreShow Less

Q: How can I follow the exercises on Windows without paying for Microsoft Visual Studio?

A: Use the Visual Studio Community edition. The Community edition has everything you need and it's free for personal use. Please follow the instructions in the movie, "Using Microsoft Visual Studio with the exercises."

Q: I stuck in the section on setting up Visual Studio 2015 for use with the exercise files. Where is the "C/C++" section in the Property dialog?

A: There's a bug in Visual Studio 2015 which prevents the C/C++ section
from appearing in an Empty project. In order to get to this section you
will need to first add a C++ file to the project. Here's how to do this:

1. Press Shift-Alt-A to "Add an existing file" to the project.
2. Select the "hello.cpp" file from the Chap01 folder of the Exercise Files and press the "Add" button.
3. Confirm that "hello.cpp" is listed under Source Files, then
right-click on the "Working" project name and select "Properties".
4. Now you should be able to select the C/C++ section and proceed with the installation video instructions.