《The C++ Programming Language》课程教学资源(PPT课件讲稿)Lecture 01 From C to C++

The c ++ Programming Language Lecture 1 From c to c++
The C++ Programming Language Lecture 1: From C to C++

Brief introduction Requirements
Brief Introduction & Requirements

Coding Style Requirements - Naming Conventions Hungarian Notation o IGlobalPrefix[TypePrefix]-BaseTag-Name [GlobalPrefix] C++ member variables start with: m Global variables start with: g Static data members start with Classes start with: C Interfaces start with: I Standard [PrefIX: A pointer. CHAR* psz g An array. DWORD rgfype[.]i pp-A pointer to a pointer. int* ppTop i h -a handle. HANdle hFile ref -A reference to. char Func(string& refResult
Coding Style Requirements -- Naming Conventions ◼ Hungarian Notation ◼ [GlobalPrefix][TypePrefix]-BaseTag-Name ◼ [GlobalPrefix] ◼ C++ member variables start with: m_ ◼ Global variables start with: g_ ◼ Static data members start with: s_ ◼ Classes start with: C ◼ Interfaces start with: I ◼ Standard [Prefix]: p – A pointer. CHAR* psz; rg – An array. DWORD rgType[…]; pp – A pointer to a pointer. int* ppTop; h – A handle. HANDLE hFile; ref – A reference to. char Func(string& refResult);

Coding Style Requirements Naming Conventions(cont) Standard“ BaseTag” void BOOL BYTE vfbd UINT >1i CHAR Double float fl WCHAR wch ULONG >u1 LONG NOI dw HRESULT hr function Name-Meaningful and Capitalizing every word NULL str USHORT, SHORT, WORD ■ Example m_pdTopofstack CTypelib -g_fSwitchForDest s SZStartingURL
Coding Style Requirements -- Naming Conventions (cont.) ◼ Standard “BaseTag” void -> v int -> i BOOL -> f UINT -> ui BYTE -> b CHAR -> ch Double -> d float -> fl WCHAR -> wch ULONG -> ul LONG -> l DWORD -> dw HRESULT -> hr fn -> function sz -> NULL str USHORT, SHORT, WORD -> w ◼ Name – Meaningful and Capitalizing every words ◼ Example ◼ m_pdTopOfStack ◼ CTypeLib ◼ g_fSwitchForDest ◼ s_szStartingURL

Coding Style Requirements Naming Conventions(cont) Let 's have some tries A flag indicates whether a C++ object has been initialized BOOL m iNitialized A Session id: dWord dwsessionID a Pointer to byte buffer BYTE* pbBuffer a global buffer to store logfile filename CHAR g SZLOgEile [MAX NUM] a pointer to a global logfile name CHAR* g ps lOgfIle;
Coding Style Requirements -- Naming Conventions (cont.) ◼ Let’s have some tries… ◼ A flag indicates whether a C++ object has been initialized: ◼ BOOL m_fInitialized; ◼ A Session ID: ◼ DWORD dwSessionID; ◼ A Pointer to BYTE buffer: ◼ BYTE* pbBuffer; ◼ A global buffer to store logfile filename: ◼ CHAR g_szLogFile[MAX_NUM]; ◼ A pointer to a global logfile name: ◼ CHAR* g_pszLogFile;

Coding Style Requirements Code Indentation 4 spaces per indent level Braces in Statements Class EXample While( foo) public / /member functions declaration if(NULl = bar) Example( w Example Funcl(ad) private #ifdef DEBUG els void Trace Value( int iValue ) #endif Func2 (bc) Func30;
Coding Style Requirements -- Code Indentation ◼ 4 spaces per indent level Class CExample { public: //member functions declaration Cexample(); ~Cexample(); private: #ifdef _DEBUG void TraceValue( int iValue ); #endif … }; While (foo) { if (NULL == bar) { Func1(ad); } else { Func2(bc); } Func3(); } ◼ Braces in Statements

Useful Concepts Review
Useful Concepts Review

Reviewing c in C++ int functionA(int iX, int iY); int functionA(int iX, int iIi functionA 3,5) The first is a declaration the second is a definition (with null statements), the third is an invoking a Declaration of a variable or function can appear many times, while definition only once iX ir- parameters,3&5- arguments
Reviewing C in C++ int functionA(int iX, int iY); int functionA(int iX, int iY) {}; functionA(3,5); ◼ The first is a declaration, the second is a definition (with null statements), the third is an invoking ◼ Declaration of a variable or function can appear many times, while definition only once ◼ iX & iY - parameters, 3 & 5 - arguments

Reviewing C in C++(cont) int iX extern int ix: int function; extern int function BO; Keyword extern? means it is only a declaration, its definition is later or external to this file, asking the compiler not to assign memory or generate code extern int functionB0ti//---invalid
Reviewing C in C++ (cont.) int iX; extern int iX; int functionB(); extern int functionB(); ◼ Keyword ‘extern’ means it is only a declaration, its definition is later or external to this file, asking the compiler not to assign memory or generate code ◼ extern int functionB() {}; //---invalid

Reviewing C in C++(cont) int funCAO static intⅸ=0 int funCAO static intⅸ=0 a Function can" remember >> ix is a local oloba/ i between calls variable” to the file But iX is unavailable Its scope is only in outside the function its this file scope is in this function
Reviewing C in C++ (cont.) int funcA() { static int iX = 0; } ◼ iX is a “local global variable” to the file ◼ Its scope is only in this file ◼ Function can “remember ” iX between calls ◼ But iX is unavailable outside the function, its scope is in this function static int iX = 0; int funcA() { … }
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 上海交通大学:《数字图像处理 Digital Image Processing》课程教学资源(PPT课件讲稿,第三版)Chapter 12 Object Recognition.pptx
- 《数据结构》课程教学资源(PPT课件讲稿)第二章 线性表.ppt
- 《C语言程序设计》课程电子教案(PPT课件讲稿)第4章 算法控制结构.ppt
- 沈阳理工大学:《大学计算机基础》课程教学资源(PPT课件讲稿)第3章 编辑排版软件(Microsoft Word 2000).pps
- 《操作系统》课程教学资源(PPT课件讲稿)内存管理 Memory Management.ppt
- 《电子商务概论》课程教学资源(PPT课件讲稿)第一章 电子商务基础知识(主讲:贾朝辉).pptx
- 南京大学:《编译原理》课程教学资源(PPT课件讲稿)第九章 机器无关的优化(赵建华).ppt
- 《计算科学基础研究》课程教学资源(PPT课件讲稿)类的定义.ppt
- 上海交通大学:《程序设计》课程教学资源(PPT课件讲稿)第9章 模块化开发.ppt
- 利用EXCEL进行数据分析与图表处理(PPT讲稿).pptx
- 北京师范大学:《多媒体技术基础》课程教学资源(PPT课件讲稿)第二章 数字图像(曾兰芳).ppt
- 上海交通大学:《通信网络》课程PPT教学课件(Communication Networks)Introduction(主讲:叶通).pptx
- 上海交通大学:《程序设计》课程教学资源(PPT课件讲稿)第4章 循环控制.ppt
- 《单片机原理及应用》课程教学资源(PPT课件讲稿)第6章 AT89S52单片机的串行口.ppt
- 中国科学技术大学:《并行计算 Parallel Computing》课程教学资源(PPT课件讲稿)并行编译简介.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)抽象数据类型 Abstract Data Types.ppt
- 《数据结构》课程教学资源:课程教学资源(PPT课件讲稿)第九章 查找表.ppt
- 东南大学:《数据结构》课程教学资源(PPT课件讲稿)动态规划.pptx
- 上海交通大学:Mining Massive Datasets(PPT讲稿).ppt
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第一章 概述(谢希仁).ppt
- 《数据库系统概论 An Introduction to Database System》课程教学资源(PPT课件讲稿)第一讲 绪论.ppt
- 《计算机网络安全技术》课程教学资源(PPT课件讲稿)第五章 防火墙技术.ppt
- 《软件测试 Software Testing》教学资源(PPT讲稿)Part 2 Testing Fundamentals.ppt
- 《C语言程序设计》课程电子教案(PPT课件讲稿)第2章 数据类型及基本运算量.ppt
- Flexsim 初级培训讲义(PPT讲稿)Flexsim Basic Training.ppt
- 清华大家:字符串匹配算法(PPT讲稿)String Matching Algorithm(Overview & Analysis).ppt
- 四川大学:《Linux操作系统》课程教学资源(PPT课件讲稿)第3章 Shell及其编程(主计:潘薇).ppt
- 面向对象程序设计语言(PPT课件讲稿).ppt
- 《面向对象程序设计》课程教学资源(课件讲稿)C++语言的面向对象特征、Java语言的面向对象特征、Python语言的面向对象特征、R语言的面向对象特征.ppt
- 安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)GNU C/C++ programming、CGI programming in GNU C/C++ language(方贤进).ppt
- 《Photoshop基础教程与上机指导》课程教学资源(PPT讲稿)第8章 简单编辑图像.ppt
- 中国科学技术大学:《计算机组成原理》课程教学资源(PPT课件讲稿)第五章 虚拟存储器(主讲:李曦).ppt
- 中国科学技术大学:《计算机视觉》课程教学资源(PPT课件讲稿)第七章 基于运动视觉的场景复原.ppt
- 计算机应用基础课程:《信息技术应用基础》教学资源(PPT课件讲稿)第一章 中文WIN98操作系统.ppt
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第十一章 复位、时钟和省电方式控制.ppt
- 中国科学技术大学:《计算机体系结构》课程教学资源(PPT课件讲稿)第6章 Data-Level Parallelism in Vector, SIMD, and GPU Architectures.ppt
- 北京航空航天大学:《程序语言设计原理》课程教学资源(PPT课件讲稿)并发程序设计语言.ppt
- 北京航空航天大学:《程序语言设计原理》课程教学资源(PPT课件讲稿)第三章 过程式程序设计语言.ppt
- 《微机原理及应用》课程教学资源(PPT课件讲稿)第4章 汇编语言程序设计.pptx
- 清华大学出版社:普通高校本科计算机专业特色教材精选《智能技术》课程教学资源(PPT讲稿课件)第4章 模糊逻辑技术(曹承志).ppt