Course List: http://www.c-jump.com/bcc/
Our course is based on the latest edition of Programming -- Principles and Practice Using C++
The textbook is aimed at beginners and fits the needs of CIS-155 quite well.
About the author: Bjarne Stroustrup's homepage
You should study at home for at least 6-9 hours every week.
You must get organized and set up a schedule to read at least one textbook chapter a week.
You must submit one Chapter Review Report every week.
You should read all handouts and tutorials posted online.
You should always prepare a list of questions and bring it to the next lecture. Discussion will follow each time we meet.
Extra points are awarded for both asking a question and answering somebody else's question in class.
Lots of reading!
Browse Textbook Chapter 1, Computers, People, and Programming
Read Textbook Chapter 2, Hello, World!
Read Textbook Chapter 3, Objects, Types, and Values
Fill out and submit Ch.2 Review
(After the lecture, to give you a head start, I will open it and we'll do parts of it together.)
Reading a chapter means writing and running small programs from the book, from the tutorials, and form your own head.
Later in the course we'll have a few Homework Programming Assignments to work on.
There will be live coding in the classroom every week.
Usable examples are posted on CIS-155 Samples web page.
The samples include selected textbook drills (posted at the end of each chapter) and other practical exercises.
Here is the classic first program:
// This is example code from Chapter 2.2 "The classic first program" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
// This program outputs the message "Hello, World!" to the monitor
#include "std_lib_facilities.h"
int main() // C++ programs start by executing the function main
{
cout << "Hello, World!\n"; // output "Hello, World!"
return 0;
}
Start Visual Studio.
Create a new project
File -> New -> Project
Make sure to select "C++ language" and "Empty Project"
Name your project, e.g. MyFirstProgram
Specify location of your project (all dirs will be created if they don't exist):
D:\CIS155\Projects
Uncheck "Create directory for solution"
Click Next
IMPORTANT! If using an earlier version of Visual Studio,
Uncheck "Precompiled header"
Check "Empty Project"
On the main menu click
View -> Solution Explorer
Right-click "Source Files", then
Add -> New Item...
and select CPP file type. Name it main.cpp. Specify Location:
D:\CIS155\Projects\MyFirstProgram\src
The src subdirectory will be created before the new source file is created. (In this course we will keep all of our C++ code in the src subdirectory.) Once added, main.cpp opens in the source code editor as an empty file.
Copy and paste the code for the classic first program.
Save the file.
Next we need to download file named std_lib_facilities.h from the book's support site: stroustrup.com/Programming
Look for the Supporting code, right-click the link to Standard library access header and save the file in your project's source subdirectory:
D:\CIS155\Projects\MyFirstProgram\src
On the main menu click
Buiid -> Build Solution
Make sure the Output panel at the bottom of your screen says
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Otherwise, you've got some error fixing to do! (More on that later)
On the main menu click
Debug -> Start Debugging
Unfortunately, our program opens the console window, prints Hello, World! and immediately closes, so we don't get a chance to see anything.
To prevent window from closing, add
keep_window_open();
statement to the program:
// This is example code from Chapter 2.2 "The classic first program" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
// This program outputs the message "Hello, World!" to the monitor
#include "std_lib_facilities.h"
int main() // C++ programs start by executing the function main
{
cout << "Hello, World!\n"; // output "Hello, World!"
keep_window_open();
return 0;
}
Repeat steps to build and run the program. If everything works, congratulations! Otherwise, you'll need to look at the error messages and fix the problems. (More on that later)
C++ is a programming language designed for a wide selection of programming tasks.
In C++, strings are delimited by double quotes (").
The \n is a special character indicating a newline.
The name cout refers to a standard output stream. Whatever characters are "put into cout" will appear on the screen.
Anything written after the token // on a line is a comment.
Comments are ignored by the compiler and written for the benefit of programmers who read the code.
The first line of the program is typically a comment that tells the human reader what the program is supposed to do. This kind of comment reminds us (the programmers) what we should tell the computer precisely, completely, and formally.
An #include directive instructs the computer to include (make available) facilities from another file.
The importance of std_lib_facilities.h (written specifically for our textbook) is that it makes the C++ standard library facilities available.
Every C++ program must have a function called main() to tell it where to start executing.
A part of a C++ program that specifies an action and isn't a pre-processing directive is called a statement.