C++ Basics(PPT讲稿)

C++ Basics
C++ Basics

Slide 2 C++ C is a programming language developed in the 1970s with the UNIX operating system C is procedural, and efficient and portable across different hardware platforms C++ is a better C. and c is a subset of c++ C programs should run in C++ C++ supports Data abstraction object-oriented programming Generic programming
Slide 2 C++ • C is a programming language developed in the 1970s with the UNIX operating system • C is ‘procedural’, and efficient and portable across different hardware platforms • C++ is a better C, and C is a subset of C++ • C programs should run in C++ • C++ supports • Data abstraction • “object-oriented” programming • Generic programming

Slide 3 The first program #include using namespace stdi int main(i cout < Hi!<< endl
Slide 3 The first program #include using namespace std; int main(){ cout << “Hi!” << endl; }

Slide 4 Variables and assignments The most fundamental programming language constructs!
Slide 4 Variables and Assignments The most fundamental programming language constructs!

Slide 5 What is a variable? A variable(also an object) is a named memory location for a value (that we can write to, retrieve, and manipulate) X 1000 Name -n identifier Type - size It can be best thought of as a container/box for a value
Slide 5 What is a variable? Name --- identifier Type --- size A variable (also an object) is a named memory location for a value (that we can write to, retrieve, and manipulate) 1000 X It can be best thought of as a container/box for a value

Slide 6 Variable names -Identifiers An identifier is a name for variables constants functions etc It consists of a letter(including the underscore)followed by any sequence of letters digits or underscores letter underscore() Names are case-sensitive. The following are unique identifiers Hello, hello, whoami, whoAMi, WhoAmI Names cannot have special characters in them e.g., X=Y, J-20,#007, etc are invalid identifiers C++ keywords cannot be used as identifiers Choose identifiers that are meaningful and easy to remember
Slide 6 Variable names --Identifiers • An identifier is a name for variables, constants, functions, etc. • It consists of a letter (including the underscore) followed by any sequence of letters, digits or underscores • Names are case-sensitive. The following are unique identifiers: Hello, hello, whoami, whoAMI, WhoAmI • Names cannot have special characters in them e.g., X=Y, J-20, #007, etc. are invalid identifiers. • C++ keywords cannot be used as identifiers. • Choose identifiers that are meaningful and easy to remember

Slide 7 Keywords(reserved words) Reserved words have a special meaning in C++ The list of reserved words asm auto, bool, break, case, catch, char class, const, continue, default, delete do double, else enum, extern, float, for friend, goto, ifr include, inline, int, long, namespace, new, operator, private, protected, public, register, return, short, signed sizeof, static, struct, switch, template this, throw, try, typedef, union, unsigned, using, virtual, void, volatile, while
Slide 7 Keywords (Reserved words) • Reserved words have a special meaning in C++. • The list of reserved words: asm, auto, bool, break, case, catch, char, class, const, continue, default, delete, do, double, else, enum, extern, float, for, friend, goto, if, include, inline, int, long, namespace, new, operator, private, protected, public, register, return, short, signed, sizeof, static, struct, switch, template, this, throw, try, typedef, union, unsigned, using, virtual, void, volatile, while

Slide 8 Variable declarations Variable declaration syntax <identifier Examples int nickel; A variable must be declared before it can be used! int main(t 5;// illegal: x was not declared what is syntax, semantics?
Slide 8 Variable Declarations Variable declaration syntax: ; Examples: int nickel; int penny; A variable must be declared before it can be used! int main(){ x = 5; // illegal: x was not declared } what is syntax, semantics?

Slide 9 a variable can be initialized in a declaration int x=3 Several variables of the same type can be declared in the same declaration( though it is better to put them on separate lines) int height, width; A variable must have only one type. For example, a variable of the type int can only hold integer values
Slide 9 • A variable can be initialized in a declaration: int x = 3; • Several variables of the same type can be declared in the same declaration (though it is better to put them on separate lines): int height, width; • A variable must have only one type. For example, a variable of the type int can only hold integer values

Slide 10 Variable initialization a variable can be initialized in a declaration int x=3 Always initialize your variables, which are not always automatically initialized Different ways of initialization int x=3 int x(3)i
Slide 10 Variable initialization • A variable can be initialized in a declaration: int x = 3; • Always initialize your variables, which are not always automatically initialized!!! • Different ways of initialization int x = 3; int x(3);
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 河南中医药大学(河南中医学院):《计算机文化》课程教学资源(PPT课件讲稿)第五章 运输层.pptx
- 南京航空航天大学:《数据结构》课程教学资源(PPT课件讲稿)第七章 图(微软精品课程建设).ppt
- 香港浸会大学:Programming Interest Group(PPT讲稿)Combinatorics & Number Theory.ppt
- 河南中医药大学(河南中医学院):《计算机网络》课程教学资源(PPT课件讲稿)第二章 物理层.ppt
- 《网络搜索和挖掘关键技术 Web Search and Mining》课程教学资源(PPT讲稿)Lecture 03 The term vocabulary and postings lists.ppt
- A Unified Approach to Route Planning for Shared Mobility.pptx
- 同济大学:《软件测试》课程教学资源(PPT课件讲稿)第6章 功能测试(朱少民).ppt
- 香港理工大学:Introduction to Matlab(PPT讲稿)Image Processing with MATLAB.pptx
- 同济大学:《机器学习》课程教学资源(PPT讲稿)决策树 Decision Tree.pptx
- 河南中医药大学:《网络技术实训》课程教学资源(PPT课件讲稿)网络建设中的关键技术(主讲:路景鑫).pptx
- 微信公众平台开发与应用(PPT讲座,谭海兵).pptx
- 《计算机常用工具软件》教学资源(PPT讲稿)第8章 音频工具.ppt
- 应用层网络(PPT课件讲稿)Application-layer Overlay Networks.ppt
- 中国科学技术大学:《信息论与编码技术》课程教学资源(PPT课件讲稿)第6章 有噪信道编码定理.pptx
- 《单片机原理与应用》课程教学资源(PPT课件讲稿)第2章 MCS-51单片机结构及原理.pptx
- 深圳大学:《编译原理》课程教学资源(PPT课件讲稿,共四章,尹剑飞).ppt
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第十章 人机交互接口(主讲:刘忠国).ppt
- 谈模式识别方法在林业管理问题中的应用(PPT讲稿).pptx
- 视觉系统(PPT课件讲稿)The Visual System.ppt
- 北京大学信息学院:《高级软件工程》课程教学资源(PPT课件讲稿)第五讲 新运行平台——云计算平台.pptx
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第五章 运输层.ppt
- 《计算机组成原理》课程电子教案(PPT课件讲稿)第4章 指令系统.ppt
- 演化计算(PPT讲稿)Evolutionary Computation(EC).ppt
- 上海交通大学:自然语言处理(PPT课件讲稿)Natural Language Processing.ppt
- 厦门大学:《大数据技术原理与应用》课程教学资源(PPT课件讲稿,2017)第4章 分布式数据库HBase.ppt
- 《软件工程》课程教学资源(PPT讲稿)软件测试——系统测试.pptx
- 香港浸会大学:《Data Communications and Networking》课程教学资源(PPT讲稿)Chapter 9 High Speed LANs and Wireless LANs.ppt
- Software Reliability & Testing(PPT讲稿)Overview of Software Reliability Engineering.ppt
- 《Java程序开发》课程教学资源(PPT课件讲稿)第11章 Struts2框架技术.ppt
- 北京航空航天大学:《数据挖掘——概念和技术(Data Mining - Concepts and Techniques)》课程教学资源(PPT课件讲稿)Chapter 02 Getting to Know Your Data.ppt
- 《计算机网络》课程教学资源(PPT课件讲稿)第三章 数据链路层.ppt
- 《信息系统与数据库技术》课程教学资源(PPT课件讲稿)第4章 T-SQL与可编程对象.ppt
- 香港理工大学:数据仓库和数据挖掘(PPT讲稿)Data Warehousing & Data Mining.ppt
- 山西农业大学:大数据技术原理与应用(PPT讲稿)Development and application of bigdata technology.ppt
- Peer-to-Peer Networks:Distributed Algorithms for P2P Distributed Hash Tables.ppt
- 中国科学技术大学:《计算机体系结构》课程教学资源(PPT课件讲稿)Chapter 01 量化设计与分析基础(主讲:周学海).ppt
- 《计算机视觉》课程教学资源(PPT课件讲稿)边缘和线特征提取.ppt
- 厦门大学:《数据库系统原理》课程教学资源(PPT课件讲稿,2016版)第五章 数据库完整性.ppt
- 四川大学:《Linux操作系统》课程教学资源(PPT课件讲稿)第2章 Linux操作系统管理基础.ppt
- 《数据结构》课程教学资源(PPT课件讲稿)第六章 树与二叉树(6.1-6.3).ppt