CSCI 1060U Lecture 01

advertisement
CSCI 1060U
Programming Workshop I
§ Professor: Dr. Jeremy S. Bradbury
§ E-­‐mail: jeremy.bradbury@uoit.ca
§ Office hour: Tuesdays 11:00am-­‐12:00pm, Thursday 3:00pm-­‐4:00pm (UA4016), otherwise by appointment
§ Teaching Assistants: Joseph Heron & Ryan Shanks
§ E-­‐mail: joseph.heron@uoit.ca, ryan.shanks@uoit.ca
§ Office hour: during labs, otherwise by appointment
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 1
CSCI 1060U
Programming Workshop I
§ Lectures:
§ Mon. 8:10am – 9:40am (UA1220)
§ Thur. 9:40am – 11:00am (UA1220)
§ Laboratories:
§ Mon. 5:10pm – 8:00pm (J123A)
§ Tues. 8:10am – 11:00am (J123A)
§ Tues. 5:10pm – 8:00pm (J123A)
Note:
• labs start next week.
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 2
CSCI 1060U
Programming Workshop I
§ This is a first intensive course on computer programming that covers both theory and practice.
§ Aims of the Course:
§ Introduce modern concepts in program design and construction § Introduce features of modern object-­oriented programming
§ Apply these concepts to practical programming problems in the lab § Topics covered – program design, problem solving strategies, program documentation, memory management and object-­oriented program design.
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 3
CSCI 1060U
Programming Workshop I
§ Textbook: § Walter Savitch, Absolute C++ (6/E)
§ This book will be the primary course reference and is a good general C++ reference.
§ It will also be used next semester in CSCI 1061U: Programming Workshop II
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 4
CSCI 1060U
Programming Workshop I
§ Website: http://www.sqrlab.ca/csci1060u/
§ Online articles and websites will be used to supplement the textbook. § Links will be posted on the course website
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 5
CSCI 1060U
Programming Workshop I
§ Topics (include but are not limited to):
§
§
§
§
§
§
§
§
Data types and variables
Branching and loops
Pre-­defined and programmer-­defined functions
Programming from the command-­line in Linux
File Input/Output
Code style & program documentation
Memory management (with pointers)
Object-­oriented programming (with classes)
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 6
CSCI 1060U
Programming Workshop I
§ Marking: Laboratories (weekly)
40%
Term Tests (2)
20%
Final Exam
40%
Note:
The schedule for tests is as follows:
• Test 1 – Thursday, Oct. 29, 2015
• Test 2 – Thursday, Nov. 26, 2015
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 7
CSCI 1060U
Programming Workshop I
§ Laboratories
§ This course will have weekly laboratories § Labs will allow students to practice the programming concepts that are covered in the lectures
§ All labs will be done individually § Labs may include both in-­lab and take-­home problems
§ Laboratory Submissions
§ Unless otherwise specified in the instructions, all laboratory work should be submitted using Blackboard
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 8
Introduction to C++
Overview
§ Today we will start to learn how to program in C++
§ Who has used C++ before?
§ We’ll start with the tools and environment – the g++ compiler and Linux
§ What is a compiler?
§ Who has used Linux before?
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 9
Command-­line compilation with g++
§ G++ is the C++ compiler in the GNU Compiler Collection (GCC)
§ We will use G++ in this class in the Linux operating system.
C++ source code
G++
Source: http://opensourcepedia.com
© J.S. Bradbury
Machine code
CSCI 1060U Lecture 1 Slide 10
Command-­line compilation with g++
§ The first step in learning how to use g++ is to compile a single file program
g++ example_program.cpp
§ The above command will compile the program and create a machine code executable call a.out which can be run by typing: ./a.out
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 11
Command-­line compilation with g++
§ If you want to name the executable something other than a.out you can use the –o option
g++ example_program.cpp –o ex_prog
§ The above command will compile the program and links it to create the executable. This is the same as doing these two steps one at a time:
g++ -c example_program.cpp
g++ example_program.o –o ex_prog
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 12
Comments in C++
Comments
§ In C++ comments can occur in two ways:
// everything from start symbol to the end of line // is a comment
or
/* Everything between the start and end symbols is a comment. */
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 13
The Basic Structure of a C++ Program
//libraries needed by your program are listed first
#include <iostream>
//the next line is needed – will explain later J
using namespace std;;
//the main function is where we will write our code
int main() {
…
return 0;;
}
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 14
C++ Input and Output
§ Input using cin
§ Output using cout
See helloclass.cpp for an example of output using cout.
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 15
Introduction to C++
Summary
§ Today we wrote our first C++ program and learned how to compile it at the command-­line in Linux
Next Time
§ Next we’ll look at the basics of writing C++ programs including: §
§
§
§
Input/output
Data types
Variables
Type casting
© J.S. Bradbury
CSCI 1060U Lecture 1 Slide 16
Download