The C++ reference type

- C++ references are very much like pointers,…but with different rules…and different semantics.…Here I have a working copy of working.cpp…from Chapter 05 of the ExerciseFiles.…Let's take a look at a quick example.…See what references are.…Let's start by just declaring an integer…and I'll give it a value.…And then I'm going to declare a reference…to that integer and that looks like this.…The & is what makes that a reference.…And then I assign it a variable…of the same type or an object of the same type.…

And that makes this reference bound to that object.…Then I can use either the reference…or the object in exactly the same way.…I can say "ir "…and when I build and run,…you'll see the value is 5.…Or, I can just say "i"…and we'll get an unused variable warning here.…It'll still say that the value is i.…And in fact, if I change the value of ir,…now the value of i is also changed.…

And so, I can use ir just as if it were i.…I can give it values.…I can assign it to other things.…I can increment it and pass it to variables.…

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,168,104

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.