中国高校课件下载中心 》 教学资源 》 大学文库

《C++程序设计教程》教学资源(PPT课件讲稿)复习

文档信息
资源类别:文库
文档格式:PPT
文档页数:17
文件大小:143.5KB
团购合买:点击进入团购
内容简介
C语言重要概念 一、常量与变量 二、数组 三、选择if .. else switch case
刷新页面文档预览

C++程序设计教程 复习

C++程序设计教程 复习

C语言重要概念 常量与变量 数组[ 癱选择if.else switch case 针 pointer 结构 struct 静态变量 static

C语言重要概念  常量与变量  数组 []  选择 if … else …  switch case  指针 pointer  结构 struct  静态变量 static

比C语言更好 输入/输出流cout>b 动态内存分配和释放 new delete 内联函数 inline 运算符概念+-*/% 引用的概念int& const限定符 函数重载

比C语言更好  输入/输出流 cout > b;  动态内存分配和释放 new delete  内联函数 inline  运算符概念 + - * / %  引用的概念 int&  const 限定符  函数重载 

类的概念 public、 protected、 private 构造函数:默认构造函数、拷贝构造函 数、默认形参 析构函数:唯一性、设为虚函数 继 运算符 友元 虚函数

类的概念  public、protected、private  构造函数:默认构造函数、拷贝构造函 数、默认形参  析构函数:唯一性、设为虚函数  继承  运算符  友元  虚函数

软件学习过程 计算机系统>编程语言>数据库>数据结构>软件工程 系统 C 数据库 软件设 可行性 组成 原理 分析 C++ 概要设 Acess 网络 计 Java FoxPro 详细设 计 SQL 软件测 试 验收

软件学习过程 C 计算机系统 编程语言 数据库 数据结构 软件工程 C++ Java 系统 组成 网络 数据库 原理 Acess FoxPro SQL 软件设 计 可行性 分析 概要设 计 详细设 计 软件测 试 验收

软件开发人员分类 岗位名称 岗位要求 网页设计师 HTML, CSS, ASP/JSP+JScrip 网络开发工程师 Java,网页设计技术,数据库开发技术 软件测试工程师 VC++,软件测试技术 软件界面工程师 VC++,软件设计技术,界面开发技术 高级多媒体开发工程|VC++,软件设计技术,多媒体开发技术 (DirectX) 游戏开发工程师 VC++,软件设计技术,动画开发技术 (DirectX) 软件算法工程师 VC++,数学,软件设计技术,某领域的算 法实现技术 系统分析员 VC++,软件设计技术,软件工程

软件开发人员分类 岗位名称 岗位要求 网页设计师 HTML,CSS,ASP/JSP+JScrip 网络开发工程师 Java,网页设计技术,数据库开发技术 软件测试工程师 VC++,软件测试技术 软件界面工程师 VC++,软件设计技术,界面开发技术 高级多媒体开发工程 师 VC++,软件设计技术,多媒体开发技术 (DirectX) 游戏开发工程师 VC++,软件设计技术,动画开发技术 (DirectX) 软件算法工程师 VC++,数学,软件设计技术,某领域的算 法实现技术 系统分析员 VC++,软件设计技术,软件工程

class array 例1 friend ostream& operator >(istream&, Array & public Array(int array Size=10); //default constructor Array(const Array &) l copy constructor ~Aray0;∥ destructor int get Size o const i return size, 1 const Array operator=(const Array &) evaluate the array int operator ==(const Array &)const; compare equivalency of arrays int operator =(const Array &)const; / compare inequality of arrays int& operator [(int); //subscript operator static int getArray Count 0; //return the number of instantiation array private int* ptr; / pointer to the first element of the array int size: static int array Count; //the number of instantiation array

例1 class Array { friend ostream& operator > (istream&, Array&); public: Array (int arraySize=10); // default constructor Array (const Array&); // copy constructor ~Array (); // destructor int getSize () const { return size; } constArray& operator = (const Array&); // evaluate the array int operator == (constArray&) const; // compare equivalency of arrays. int operator != (const Array&) const; // compare inequality of arrays. int& operator [] (int); // subscript operator static int getArrayCount (); // return the number of instantiation array. private: int* ptr; // pointer to the first element of the array. int size; static int arrayCount; // the number of instantiation array. };

// initialize the static data member int Array: arrayCount 0 例1 // return the number of instantiation array int Array:: getArrayCount ([ return arrayCount; y // constructor Array:: Array(int arraysize) +tarrayCount; // counter increase size arraysize; / default size of the array is 10 ptr new int [size assert(ptr =0) // to make sure if allocate memory is success for (int i=0; i size; i++)// initialize the array ptr[i]=0;

例1 // initialize the static data member. int Array::arrayCount = 0; // return the number of instantiation array. int Array::getArrayCount () { return arrayCount; } // constructor Array::Array(int arraySize) { ++arrayCount; // counter increase. size = arraySize; // default size of the array is 10. ptr = new int [size]; assert(ptr != 0); // to make sure if allocate memory is success for (int i=0; i < size; i++) // initialize the array. ptr[i] = 0; }

7/constructor Array:: Array (const Array& init) 例1 +tarrayCount; // counter increase size= init size; / default size of the array is 10 ptr new int [size]i assert ptr = 0)i 7/ to make sure if allocate memory is success for (int i=0 size: i++)// initialize the array ptr[i] init ptr [i]i // destructor Array:: aRray ( arraycount // counter decrease delete [ ptr; / release the memory

例1 // constructor Array::Array (const Array& init) { ++arrayCount; // counter increase. size = init.size; // default size of the array is 10. ptr = new int [size]; assert(ptr != 0); // to make sure if allocate memory is success for (int i=0; i < size; i++) // initialize the array. ptr[i] = init.ptr[i]; } // destructor Array::~Array () { --arrayCount; // counter decrease. delete [] ptr; // release the memory }

// overload evaluate operator const Array& Array: operator =(const Array& right) if( &right ! this 例1 delete[] ptr; / release current memory size right size ptr new int [size] assert (ptr != 0)i for int i=0; i< size; i++ ptr[i] right. ptrli] return *this

例1 // overload evaluate operator const Array& Array::operator = (const Array& right) { if ( &right != this ) { delete[] ptr; // release current memory. size = right.size; ptr = new int [size]; assert (ptr != 0); for ( int i=0; i < size; i++ ) ptr[i] = right.ptr[i]; } return *this; }

共17页,试读已结束,阅读完整版请下载
刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档