- 博客(17)
- 收藏
- 关注
原创 calculator
There is a class named Calculator. It has a member function getResult() which can calculate the value of the expression. Please complete the design and implementation of the class.Something you shou
2014-06-06 21:48:56 596
原创 list用法
List将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢.list对象函数assign() 给list赋值 back() 返回最后一个元素 begin() 返回指向第一个元素的迭代器 clear() 删除所有元素 empty() 如果list是空的则返回true end() 返回末尾的迭代器 erase()
2014-05-18 16:47:50 509
原创 map的使用&实现不同单词的计数器
Sample input:3abc 123 abc iie I hate TA Sample output:27 4
2014-05-16 23:20:54 523
原创 map的嵌套使用
涉及到STL里面map与set的使用,作为初学者的学习记录下来An ip can login several qqs, and a qq can be logined by several ips.Your task is to find which qqs have been logined by the ip and which ips have logined the qq.
2014-05-16 23:14:56 1069 1
转载 valgrind使用
==2326== Memcheck, a memory error detector==2326== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.==2326== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info==2326== Com
2014-05-11 17:53:09 468
原创 大一下学期复习期中考
1、文件的输入输出:fstream infile ofstream outfile; int income, tax; infile.open(“FILENAME1”); // open the files outfile.open(“FILENAME2”); while ( infile >> income ) { if ( income
2014-05-10 10:34:36 600
转载 C++ 引用变量
引用的定义:引用是定义已定义的变量的别名(另一个名称)。引用一般用途:引用变量的主要用途是用作函数的形参,通过将引用变量做参数,函数将使用原始数据,而不是拷贝。创建引用变量:int i;int & j = i; 此处& 符号不是地址符 是用来类型标识符的一部分,就像声明中的int*指向int的指针,int& 是指向int的引用。以上代码等价于 int* const j=
2014-05-05 10:12:53 542
原创 Class streamManipulator(for hw) cout的应用
题目:Now you are required to design a class named streamManipulator.The class can receive an integer as input and output the its corresponding value in decimal, octal and hexadecimal forms.And it ca
2014-05-02 21:03:34 521
转载 C++函数重载、重定义、重写
1.重载:要求函数名相同,参数列表不同,重载只是在类的内部存在。与返回类型无关,故不能靠返回类型来判断重载;2.重定义(隐藏):要求函数名相同,函数类型为非虚函数,与返回类型、函数参数列表无关。重定义是发生在继承子类与父类之间。当子类的函数名和参数列表和父类相同时,这是要看父类函数是否是virtual虚函数,如果是则是重写,如果不是则是重定义;3.重写(覆盖):要求函数名相同,参数列表
2014-04-20 09:31:15 638
转载 单例模式C++实现
单例模式有许多种实现方法,在C++中,甚至可以直接用一个全局变量做到这一点,但这样的代码显得很不优雅。定义一个单例类,使用类的私有静态指针变量指向类的唯一实例,并用一个公有静态方法获取该实例。如下面的类定义: class CSingleton: { // 其它成员 public: static CSingleton * GetInstance() { if (m_pInst
2014-04-18 16:03:32 438
原创 实现字符串
#include #include #include "String.h"#include using namespace std; String a, b("MFGZ!");String c = b; void display() {cout << a.empty() << " " << a.length() << " " << a << endl;cout << b.em
2014-04-18 15:12:35 516
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人