📄 02.txt
字号:
CS 1355
Intro to Programming in C
Thursday 2006.9.14 (Week 1)
Lecture Notes (at http://r638-2.cs.nthu.edu.tw/C/notes/02.txt)
Introduction (Chapter 1 continued)
- Announcements
- Compiler vs. Interpreter
- C++ and Java
- Standard I/O
- Internet
Announcements: Office hours
- Professor: (Room EECS 638)
Mon 1pm-2pm, Thu 3pm-5pm
- TA: (Room EECS TA room)
Tue 10am-12pm, Wed 10am-12pm
More on Compiler vs. interpreter
- CC: C-compiler
- compile C source code, outputs an executable file
- run the executable file
- Shell (c-shell, bash, etc): interpreter
- type a command (e.g., "ls")
- get result immediately on the screen, no compilation
("ls" is an executable, but the shell interprets "ls" by
calling the "loader" to run it)
=> you can find out where the executable is located, by typing
% which ls
/bin/ls
("which" itself is a command interpreted by the shell)
% which which
which: shell built-in command
% which vi
/usr/bin/vi
Note: / is the top level directory.
/usr is the "usr" directory from the top
/usr/bin is the "bin" directory inside "/usr"
Interpreters can do much more than shell
- example: python, an interpreted language
% python
>>>
Note: >>> is the python prompt
>>> x = 2
>>> y = 3
>>> x + y
5
>>>
Each line is interpreted when it is typed in.
No need for compilation.
=> quick way to get an answer
What is C++?
- "object-oriented" extension of C
- a different way of "packaging" data and program.
- example: data=picture, program=to resize to x, y
- Regular C, "procedure oriented" way:
resize(picture, 100, 200);
- in C++, "object oriented" way
picture.resize(100, 200);
- so, why is it useful?
reason 1: put related program code together, better organization.
Example,
picture.resize(...)
picture.rotate(...)
picture.clip(...)
picture.mirror(...)
reason 2: inheritance
Example,
initially, you write programs for black-and-white pictures.
later, you make color pictures.
Conceptually, resize(), rotate(), clip(), ... are the same for user
Inheritance:
lets color pictures use the same function as black-and-white,
also allows color pictures to use new functions
colorPicture.setSaturation(...) 眒︹緻
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -