Sign in to follow this  
  • entries
    570
  • comments
    2427
  • views
    216029


5 Comments


Recommended Comments

Hi Class,

Some of the topics I covered today were a bit unclear. I wanted to touch on a few of them, but will discuss these and some other topics in more detail in class on Wednesday.

1) "cin >> ...;" AND "cout << ...;"

It was pointed out to me that there might be some confusion of >> and << with bitwise shift operators.

I wanted to clarify that in the above context ">>" and "<<" are simply operators that have been defined for the purposes of inputting data to a stream (">>") or outputting data to a stream ("<<")

So:

int x;
cin >> x; // read input from standard input device and send to the stream cin

cout << x; // send the value of x to the standard output device

2) References vs. pointers.

The basic differences are these:

- references must be initialized at the time of declaration. References have automatic dereferencing. This means there is no special symbol needed to dereference (get the memory contents of the reference's address) a reference variable.

- Pointers don't have to be initialized at the time of declaration. * needs to be used to dereference (access the contents of memory pointed to by the pointer) a pointer variable.

The best way to understand some of these differences is to play with a program and watch what it does. I have attached a sample commented test.cpp file that you can build in MS VS .NET which illustrates some of the notational differences.

If you have a question about whether a particular notation will work, or what it will do. Try changing it in this test program and see what results you get.

3) .cpp vs. .h files. I will discuss this in more detail in class.

-Michele

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now