摘要: 一直很难理解返回引用:返回哪个对象的引用?返回的引用如何使用? 一、返回值 1. 示例: 2. 解读:此函数返回变量 a 的值时,要产生一个临时变量保存 a 的值,又因为临时变量的生命周期是短暂的,所以该函数的返回结果不能作为左值。 3. 运用:返回值的函数只能作为右值使用,且看下面: 二、返回类型 阅读全文
posted @ 2017-10-14 18:03 GGBeng 阅读(849) 评论(0) 推荐(1) 编辑
摘要: 7.1 1 #include <iostream> 2 #include <vector> 3 #include <cctype> 4 #include <string> 5 #include <iterator> 6 #include <initializer_list> 7 #include < 阅读全文
posted @ 2017-10-14 12:21 GGBeng 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 1.20 头文件: 1 #ifndef SALESITEM_H 2 // we're here only if SALESITEM_H has not yet been defined 3 #define SALESITEM_H 4 5 // Definition of Sales_item cla 阅读全文
posted @ 2017-10-14 11:49 GGBeng 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 一、函数指针 1. 函数类型:由它的返回类型和形参类型共同决定(与函数名无关) 2. 示例: 该函数的函数类型为:int (int, int) 3. 声明一个指向函数的指针:int (*pf)(int, int); 4. 函数名:作为一个值来使用时,该函数自动转换成指针 5. 为函数指针赋值:pf 阅读全文
posted @ 2017-10-14 10:04 GGBeng 阅读(193) 评论(0) 推荐(0) 编辑