学习篇---标准库类型中细节巩固问题
2014-10-06 10:16
204 查看
标准库string类型
1.string类型的初始化
2.string类型的输入操作符注意的问题
3.getline 读取整行文本
4.string中的size的返回类型是什么?为什么不能返回int型?
5.string'中和字符串字面值的连接 (+操作符) 加操作符返回的是string对象
6. string 对象s, s[s.size()-1] 表示的是什么
7. 采用C标准库头文件的C++版本
标准库vector类型
1.vector对象的定义和初始化
2.vector对象的操作
3. 求count的值
4.vector的下标操作只能用于获取已存在的元素,必须是已存在的元素才能用下标操作符进行索引。通过下标操作进行赋值时,不会添加任何元素。
5.区分const_iterator 和 const的iterator (3.21)
标准库bitset类型
1.初始化bitset对象的方法
2.测试题:考虑这样的序列:1,,2,3,5,8,13,21,给定一个空的bitset对象,编写一小段程序把相应的数位置1
注意:设置为1的数位的位编号符合斐波那契数列的规律
总结:今天主要温习巩固标准库类型中需要注意的小细节问题,问题涉及的不够全面,后续继续添加
1.string类型的初始化
2.string类型的输入操作符注意的问题
3.getline 读取整行文本
4.string中的size的返回类型是什么?为什么不能返回int型?
5.string'中和字符串字面值的连接 (+操作符) 加操作符返回的是string对象
6. string 对象s, s[s.size()-1] 表示的是什么
7. 采用C标准库头文件的C++版本
标准库vector类型
1.vector对象的定义和初始化
2.vector对象的操作
3. 求count的值
/** * Copyright (C) 2014, CSU * All rights reservedl * File Name:test.cpp * Author: lmm * Date of completion: 2014/10/6 * Version: v1.0 * * Problem description:read words from the standard input and store them as elements in a vector,count numbers of whitespace-separated string * Input description: input words * Program output: an integer */ #include <iostream> #include <string> #include <fstream> #include <cctype> #include <vector> using namespace std; #define MAX_PATH 260 int main() { vector<string> text; string word; vector<string>::size_type cnt = 0; while(cin >> word ) { ++cnt; text.push_back(word); } cout << "Count: " << cnt << endl; return 0; }
4.vector的下标操作只能用于获取已存在的元素,必须是已存在的元素才能用下标操作符进行索引。通过下标操作进行赋值时,不会添加任何元素。
5.区分const_iterator 和 const的iterator (3.21)
标准库bitset类型
1.初始化bitset对象的方法
2.测试题:考虑这样的序列:1,,2,3,5,8,13,21,给定一个空的bitset对象,编写一小段程序把相应的数位置1
/** * Copyright (C) 2014, CSU * All rights reservedl * File Name:test.cpp * Author: lmm * Date of completion: 2014/10/6 * Version: v1.0 * * 问题描述:考虑这样的序列:1,,2,3,5,8,13,21,给定一个空的bitset对象,编写一小段程序把相应的数位置1 * 输入描述: 空的bitset对象 * 程序输出: 输出bitset对象的位模式 */ #include <iostream> #include <bitset> using namespace std; int main() { bitset<32> bv; int x = 0, y = 1, z; z = x + y; while(z <= 21) { bv.set(z); x = y; y = z; z = x + y; } cout << "The value of all bits of bv :" << endl << bv << endl; return 0; }
注意:设置为1的数位的位编号符合斐波那契数列的规律
总结:今天主要温习巩固标准库类型中需要注意的小细节问题,问题涉及的不够全面,后续继续添加
相关文章推荐
- 学习ASP.NET中的细节问题
- 关于C#中的DateTime类型的细节问题
- VS2005+ACCESS2003开发中遇到的“标准表达式中数据类型不匹配”问题解决方法
- C++ Primer 学习笔记——第3章:标准库类型 vector
- C++ Primer 学习笔记——第3章:标准库类型 string
- 标准C程式库--问题例--类型 String
- Java第一课 Java的一些基本概念,Java的起源、为什么我们要学习Java语言,Java跨平台原理剖析;Java环境变量的配置,初学者常犯的问题,Java语言的基本数据类型和Java的语句。
- 变量数据类型选择--小细节大问题
- 【学习心得】-标准输出与简单数据类型特例列举-1
- [C++ primer 学习笔记][03]标准库类型
- 关于C#中的DateTime类型的细节问题
- 关于Access中“标准表达式中数据类型不匹配”的问题
- 关于C#中的DateTime类型的细节问题
- 关于C#中的DateTime类型的细节问题
- 关于学习MSDN中"创建自定义字段类型和字段控件"的一些心得跟问题。
- 网页设计问题大搜集(有些细节的问题,很值得学习)
- 网页设计问题大搜集(有些细节的问题,很值得学习)
- 容易被忽略的细节(2):使用泛型类和泛型方法解决【动态类型】问题
- 工作学习笔记——C#自定义类型剪贴板操作、自定义鼠标光标定位问题
- 网页设计问题大搜集(有些细节的问题,很值得学习)