0% found this document useful (0 votes)
13 views29 pages

1 CPP Introduction Final

Uploaded by

drocsit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views29 pages

1 CPP Introduction Final

Uploaded by

drocsit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Lecture 1: Introduction

Harbin Institute of Technology ( Shenzhen )


School of Computer Science and Technology
Zhang Meishan ([email protected])
Copyright : Harbin Institute of Technology , Su Xiaohong , [email protected]
Basic Information
School of Computer Science and Technology

Teacher : Zhang Meishan

https://zhangmeishan.github.io/

Teacher Assistant : Jiaxin Xu , Jinpeng Huang , Yan Luo

Office : L1922

Course group number : 892362595

Main textbooks 《 Learn C++ through English and Chinese 》


--Paul Kelly, Su Xiaohong
Score : homework 20 points + experiment 40 points + final exam 40 points
Course Teaching Objectives
• Mastering the fundamental approach to solving problems using computers
• Mastering the basic knowledge of high-level language programming
• Mastering the fundamental methods of computer software design and
implementation
• Having the ability to solve practical problems using computers and
possessing basic programming debugging skills

How to Think How to program


Like a Computer Scientist Like a Computer Scientist
First Lesson : Overview
• What is a computer program?
• How to develop a computer program?
• The brief history of the C++ language
• The common basic standards in the C++
• How to use the online programming tool, e.g. "onlinegdb“
• How to use the C++ programming tool
• How to learn C++
1.1 What is a computer program?
• computer program : A computer performs all of these
tasks by following a predefined set of instructions.

compiler

computer computer programming language machine language


program (high-level languages) (low-level languages)

cooker recipe nature language


1.1 What is a computer program?
• program language : 
natural language :
Please print “I love c++
programing” onto the screen.
1.2 Developing a computer
program
• Developing a computer program:
• define and understand the problem to be solved----analysis phase
• how is it to be done? -----design phase
• writing, compiling and testing C++ programs.
1.2 Developing a computer
program
Program development cycle
• Step 1: Design the program.
• Each program has to be individually designed to implement the overall solution
developed at the analysis and design phases.
• check its logic before starting to write the program

• Step 2: Write the program.


• the C++ program instructions are typed into a file using a text editor

source code or the program code source file


1.2 Developing a computer
program
• Step 3: Compile the program.
• translate the C++ program instructions to machine instructions through a
compiler--object code, and stores the object code in an object file.
• errors ---- compile-time syntax error: missing punctuation , misspellings,…
• warning message: not as serious as a syntax error, not prevent the program from
being compiled, may be a problem and should be investigated

• Step 4: Link the program.


• combining the object file of the program with other object files from the C++ run-
time library to form an executable file
1.2 Developing a computer
program
• Step 5: Test the program.
• run-time error—causes the program to stop before it has completed its task
• logic errors(bugs)---The program may complete its task but produce incorrect
results

• Step 6: Debug the program.


• The process of locating and correcting program errors is called debugging
• Many compilers have tools that can be used to help locate bugs
• Correcting bugs involves going back to step 2, try to catch errors as early as
possible
1.2 Developing a computer
program
Program development cycle
Design propose an overall solution

Write write C++ program instructionssource file

correct
translates C++ program instructions into
Compile run-time
machine instructionsobject file
error

Link combines the object file with the C++ run-


Correct time library filesexecutable file

Test verify program errors (bugs)

Debug locate and correct bugs


1.3 Brief history of C++
• 1972 , AT&T, Bell Lab. Dennis Ritche, C programming language
• 1980, Bell Lab. Bjarne Stroustrup, “C with Classes”
• 1983, C++ was developed by Bjarne Strostrup at AT&T Bell
Laboratories
• 1985, the first commercial version of C++
• 1997, ANSI (American National Standards Institute) C++ (standard C+
+)
C++ is always evolving !!!
1.4 Common standards in the C++

• The example programs used in this book conform to the


ANSI/ISO C++ standard.
• Not all compilers conform to this standard, so some compilers may
not correctly compile the example programs.
• Some of the example programs may have to be modified for use
with these other compilers.
• See the web site for details.
1.5 Online Programming
onlinegdb: https://www.onlinegdb.com/
1.6 Offline Programming
CodeBlocks
download CodeBlocks and install it
1.6 Offline Programming
CodeBlocks
The installation package includes the compilation environment, and
the installation will automatically find the environment path.
Therefore, you can directly create new files to write and run C++
programs.
1.6 Offline Programming
Visual Studio Code
• 1. download Visual Studio Code and install it
1.6 Offline Programming
• 2. download MinGW-W64 and install it
VS Code is just an editor — you need a compiler:
1.6 Offline Programming
• 3. After finishing the installation, open MSYS2 and enter the following
command to install the toolchain:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain

• 4. Configure system environment variables

Open the Control Panel Click "System and Security" Click "System"

Click "Advanced system settings" Click " environment variables "

Add MSYS2 bin path to user variables path MSYS2 bin path : installation path of MSYS2 +
ucrt64\bin
for example, C:\msys64\ucrt64\bin
1.6 Offline Programming
1.6 Offline Programming
• 5. use the following commands to test the installation of
environment:
1.6 Offline Programming
• 6. open Visual Studio Code, search for "C++" in extensions and install it:

Open VS Code → go to Extensions (Ctrl+Shift+X) → install:


• C/C++ (by Microsoft) → provides IntelliSense, debugging.
• C/C++ Extension Pack (optional, includes debugger and more).
• Code Runner (optional, for quick running code).
1.6 Offline Programming
• 7. test whether vscode can run c++ files
1.6 Offline Programming
• 7. test whether vscode can run c++ files
1.6 Offline Programming
• 7. test whether vscode can run c++ files
1.6 Offline Programming
• 7. test whether vscode can run c++ files
1.7 Learning C++
• A successful approach to learning to program in C++ depends on large
amounts of practice.
• exercises at the end of each chapter.
• solutions to selected exercises are at the web site for this book
http://www.hxedu.com.cn.

Other learning materials

Learn C++ – Skill up with our free tutorials (learncpp.com)

https://www.bilibili.com/video/BV1oD4y1h7S3/?spm_id_from=333.337.sear
ch-card.all.click&vd_source=1e2cfa9e6c262e6d189fe4a48f2c1aac

Learn C++ | Codecademy

Q&A
ZhangMei
Shan
Homework
• 1. How to develop a C++ program?
• 2. Use CodeBlocks, Visual Studio Code or online
programming to write a C++ program:
Display the following two sentences on the screen:
Hello C++.
I like programming.
The output is formatted as two lines.

You might also like