自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 收藏
  • 关注

原创 Data Structures and Algorithm Analysis in c++ 第一章笔记和部分习题

注:输入问题懒得搞, A 表示A的X次方 logA(B) 表示底数为A,真数为B 加减乘除等 +-*/= 指数 exponent A * A = A A / A = A A = A A + A = 2 * A != A 2 + 2 = 2 * 2 = 2 对数 Logarithms 在计算机科学中,所有对数的底数默认为2  定义:  

2015-04-02 18:12:05 740

原创 c++ primer(第五版)笔记 第十四章 重载运算与类型转换

// 重载运算符: 其函数名由operator关键字和定义的运算符号组成// 其参数数量与该运算符作用的运算对象数量一致// 对于二元运算符来说,左侧运算对象传递给第一个参数,右侧运算对象传递给第二个参数// 除 operator() 外,其他重载运算符都不能含有默认实参// 如果该函数是一个成员函数,则其第一个运算对象绑定到隐式的 this 指针上// 不能被重载的运算符: //

2015-03-24 18:38:22 490

原创 译自five popular myths about c++ --by Bjarne Stroustrup (5)

Myth 5: "C++ is for large, complicated, programs only"c++ 只是用于大型复杂的程序C++ is a big language. The size of its definition is very similar to those of C# and Java. But that does not imply that y

2015-02-01 23:18:25 616

原创 译自five popular myths about c++ --by Bjarne Stroustrup (4)

Myth 4: "For efficiency, you must write low-level code"为了效率,你必须编写底层代码Many people seem to believe that efficient code must be low level. Some even seem to believe that low-level code is inher

2015-02-01 23:14:39 523

原创 译自five popular myths about c++ --by Bjarne Stroustrup (3)

Myth 3: "For reliable software, you need Garbage Collection"作为可以信赖的软件,垃圾回收机制不可少Garbage collection does a good, but not perfect, job at reclaiming unused memory. It is not a panacea. Memory can

2015-02-01 16:31:27 930

原创 译自five popular myths about c++ --by Bjarne Stroustrup (2)

Myth 2: "C++ is an Object-Oriented Language"c++ 是面向对象的语言No. C++ supports OOP and other programming styles, but is deliberately not limited to any narrow view of “Object Oriented.” It supports

2015-01-27 11:59:29 541

原创 译自five popular myths about c++ --by Bjarne Stroustrup (1)

原文:https://isocpp.org/blog/2014/12/five-popular-myths-about-c-bjarne-stroustrupMyth 1: "To understand C++, you must first learn C"想要理解c++,必须先学cNo. Learning basic programming using C++ is far e

2015-01-26 17:18:58 763

原创 c++ primer(第五版)笔记 第十三章(4) string 类和 vector<string> 容器的简单实现

string 类和 vector 容器的简单实现str.h#ifndef __STR_H#define __STR_H#include #include #include class Str{ // 输出 friend std::ostream &operator<<(std::ostream &, const Str &); // 输入 friend std

2015-01-05 18:57:36 443

原创 c++ primer(第五版)笔记 第十三章(3) 拷贝控制

//folder.h#ifndef __FOLDER_H#define __FOLDER_H#includeclass Message;class Folder{ friend class Message; friend void swap( Message&, Message&);public: Folder(){} Folder( const Folder&); Fol

2014-12-30 10:24:39 391

原创 c++ primer(第五版)笔记 第十三章(2) 拷贝控制

#include#include// 行为像值的类class HasPtr{public: friend void swap( HasPtr& lhp, HasPtr& rhp); HasPtr( const std::string &s = std::string()): ps( new std::string( s)), num( 0) { std::cout <<

2014-12-30 10:21:08 390

原创 c++ primer(第五版)笔记 第十三章(1) 拷贝控制

// 类的拷贝控制操作 // 拷贝构造函数 copy constructor // 如果一个构造函数,第一个参数是自身类型的引用,且任何额外参数都有默认值,如果是非引用类型,则会调用拷贝构造函数,无限循环。。。 // 通常拷贝构造函数 ,不应该是一个 explicit的,好多时候需要类型转换 // 如果没有定义拷贝构造函数,编译器会合成一个拷贝构造函数 // 通常第一个参数是

2014-12-25 23:08:11 369

原创 c++ primer(第五版)笔记 第十二章 动态内存(2)

// 动态数组#inlcude #inlcude int main(){ // 分配要求数量的对象,返回第一个对象的指针 // []内必须是整型,不要求常量 // ()内为初始化值 int *p = new int[ 99]( 0); // 可以分配大小为0 的动态数组,但不能解引用 int *p1 = new int[0]; // 动态数组的释放 // 释放动态数

2014-11-11 18:21:01 372

原创 c++ primer(第五版)笔记 第十二章 动态内存(1)

// 静态内存(static) 局部static, 类static, 定义在任何函数之外的变量,由编译器自动创建和销毁,程序使用前创建,程序结束时销毁,// 栈(stack) 函数内的非static 对象,由编译器自动创建和销毁,仅在其定义的程序块运行时存在// 堆(heap) 动态分配的对象,运行时分配的对象,程序显式的销毁// 动态内存的管理 // new 在动态内存中为对象

2014-11-07 15:58:51 395

原创 c++ primer(第五版)笔记 第十一章 关联容器

// 关联容器(associative container) // 两类容器: // map key-value // set key // 八种关联容器: // 3种分类方式 // 1.或者是一个 set, 或者是一个 map // 2.或者要求关键字不重复,或者允许关键字重复 // 3.或者按顺序保存元素,或者无序保存 // m

2014-10-26 15:27:30 439

原创 c++ primer(第五版)笔记 第十章 泛型算法(1)

// 泛型算法(generic algorithm),大部分定义在 algorithm.h 中,numeric.h 定义了一组数值泛型算法 // 1>访问序列中首元素 // 2>元素运算 // 3>满足条件,返回结果 // 4>否则继续查找 // 5>到达序列尾,停止 // 6>返回未找到的值,类型同3一样 // 除步骤2外,都可以使用迭代器操作,所以不依赖容器 // 但步骤2

2014-09-27 08:43:29 355

原创 c++ primer(第五版)笔记 第十章 泛型算法(4)

// istream_iterator 操作// istream_iterator in(is) in 从输入流 is 中读取类型为 T 的值// istream_iterator end 表示尾后位置// in1 == in2 in1 和 in2 必须读取相同类型,如果他们都是尾后迭代器,或绑定到相同的输入,则相等// in1 != in2// *in 返回流中读取的值//

2014-09-26 22:53:23 607

原创 c++ primer(第五版)笔记 第十章 泛型算法(3)

// 流迭代器(stream iterator) // istream_iterator 读取输入流 // ostream_iterator 写入输出流// 反向迭代器(reverse iterator)// 移动迭代器(move iterator)#include#include#include#includeusing std::deque;using std::cin

2014-09-26 22:52:31 416

原创 c++ primer(第五版)笔记 第十章 泛型算法(2)

#include#include#include#includeusing std::cout;using std::cin;using std::endl;using std::vector;using std::string;//_1 占位符的空间using namespace std::placeholders;inline string make_plural( s

2014-09-26 22:51:37 442

原创 c++ primer(第五版)笔记 第九章 顺序容器(3)

// 容量管理 // 将 capacity 减少到和 size() 相同 // 用于 vector string deque // 不一定执行 // c.shrink_to_fit() // 不重新分配内存的话,c 可以保存多少元素 // 用于 vector string // c.capacity() // 分配至少能容纳 n 个元素的空间 // 用于 vector s

2014-09-04 08:45:41 713

原创 c++ primer(第五版)笔记 第九章 顺序容器(4)

// string 操作 // 修改操作 // s.append(args) 在 s 末尾追加 args, 返回 s 的引用 // s.replace(range, args) 将 range 范围替换为 args , 返回 s 的引用,range 可以是一个下标加一个长度也可以是一对迭代器 // s.assign(args) 将 s 替换为 args 指定的字符, 返回 s 的引用

2014-09-04 08:44:04 398

原创 c++ primer(第五版)笔记 第九章 顺序容器(2)

// 顺序容器// 添加元素(array 除外) // 在尾部创建一个值为 t 或由 args 创建的元素,返回 void,不支持 forward_list // c.push_back(t) // c.emplace_back(args) // 在头部创建一个值为 t 或由 args 创建的元素,返回 void,不支持 vector 和 string // c.push_fr

2014-09-02 18:19:22 480

原创 Linux 修改时区的方法

tzselect 查找适合于本地的时区此命令仅显示时区信息,方便后面的设置。比如中国标准时间,变量TZ应设为Asia/Shanghai修改/etc/localtime文件(个人常用)cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #覆盖原来的localtime文件,或者#ln -sf /usr/share/

2014-08-30 17:14:46 414

原创 Centos 的网络设置

a)/etc/sysconfig/network[feng@localhost network-scripts]$ cat /etc/sysconfig/networkNETWORKING=yesNETWORKING_IPV6=yes#HOSTNAME=localhost.localdomain        //为什么要把主机名注释掉,一般先解析主机名

2014-08-30 17:14:20 377

转载 CentOS添加源(EPEL、Remi、RPMForge)

CentOS自带的CentOS-Base.repo源中有时候找不到需要的软件,或者安装的版本不够新或稳定,下面的源可以帮你解决这些问题EPEL源EPEL,即Extra Packages for Enterprise Linux,是由 Fedora 社区创建维护,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。EPEL中含有大量的软

2014-08-30 17:10:37 490

原创 c++ primer(第五版)笔记 第九章 顺序容器(1)

// 顺序容器(sequential container) // vector 可变大小数组,快速随机访问,在尾部之外的位置插入或删除元素可能很慢 // deque 双端队列,快速随机访问,在头尾快速插入或删除 // list 双向链表,双向顺序访问,任何位置均可快速插入 // forward_list 单向链表,单向顺序访问,任何位置均可快速插入 // array (非内置的 arra

2014-08-30 17:10:04 397

原创 c++ primer(第五版)笔记 第八章 io

// iostream 头文件 // istream, wistream 从流读取数据 // ostream, wostream 向流写入数据 // iostream, wiostream 读写流// fstream 头文件 // ifstream, wifstream 从文件读取数据 // ofstream, wofstream 向文件写入数据 // fstream, wfstr

2014-08-28 19:20:30 364

原创 c++ primer(第五版)笔记 第七章 类初探

#ifndef SALES_DATA_H#define SALES_DATA_H#include #include using std::cout;using std::cin;using std::endl;using std::cerr;using std::istream;using std::ostream;using std::string;// 类的基本思想:

2014-08-28 10:14:19 498

原创 c++ primer(第五版)笔记 第六章 函数(2)

#ifndef FUNC_H#define FUNC_H#include#include#include#includeusing std::cout;using std::cin;using std::endl;using std::string;using std::vector;char &get_val(string &s, string

2014-08-23 17:06:19 346

原创 c++ primer(第五版)笔记 第六章 函数(1)

doub.h#ifndef DOUB_H#define DOUB_H#includeusing std::cout;using std::endl;using std::cin;int doub(int n); //函数必须在使用前声明,可以多次声明,但只能定义一次//如果这个函数永远不会用到,可以只有声明没有定义//返回类型,函数名,形参列表描述了函数

2014-08-16 00:58:43 329

原创 linux 下普通账号 su 命令提示 “no such file or directory” 的解决办法

1./etc/passwd 文件:格式是否是unix,root行是否缺失信息,root最后一项的shell是否与执行的shell一致,一般为 /bin/bash2.不能切换到root 的账号:是否将su命令 alias 到另一个无效目录,在.bash_profile中是否存在 alias su = xxx的命令,如果找不到可以使用 \su - 原始命令

2014-08-14 16:52:17 15922

原创 c++ primer(第五版)笔记 第五章 语句

#include#include#includeusing std::cout;using std::endl;using std::cin;using std::string;using std::runtime_error;class Test{public: Test(int tp = 0):ti(tp) { cout << "new!" << ti << e

2014-08-14 16:40:49 387

原创 makefile 简介

make 1.简单的命令格式target : prerequisitesrecipetarget 通常是一个程序生出的文件名,比如对象文件(.o),也可能是一个将要执行的动作命令 比如 cleanprerequisites 通常是一个或多个生成 target 所需要的文件recipe 是 make 要执行的方法,可以一个或多个,可以使一行或多行,注意每行都需要 tab

2014-08-12 12:11:44 354

原创 c++ primer(第五版)笔记 第四章 表达式

#include#include#include#includeusing std::cout;using std::cin;using std::endl;using std::string;using std::vector;void practice_4_5();void practice_4_6();void practice_4_20(

2014-08-12 02:06:19 405

原创 c++ primer(第五版)笔记 第三章(4)数组

#include#include#include#includeusing std::cout;using std::cin;using std::endl;using std::string;void practice_3_28();int practice_3_36(int *, int *, int *, int *);void practic

2014-08-07 02:20:49 384

原创 c++ primer(第五版)笔记 第三章(3)iterator初探

#include#include#includeusing std::string;using std::vector;using std::cout;using std::endl;using std::cin;void practice_3_23();void practice_3_22();void practice_3_24();void p

2014-08-03 19:24:09 468

原创 c++ primer(第五版)笔记 第三章(2)vector 库初探

#include#include#includeusing std::string;using std::vector;using std::cout;using std::endl;using std::cin;void vector_test();void practice_3_16();void practice_3_20();int

2014-08-02 16:31:53 438

原创 c++ primer(第五版)笔记 第三章(1)string类

//#define NDEBUG#include#include#include//using namespace std;//using 声明不应该出现在头文件中,会使每个包含头文件的文件都会有这个声明,造成名字冲突using std::cout;using std::cin;using std::endl;using std::string;

2014-08-02 01:55:33 418

原创 c++ primer(第五版)笔记 第二章(4)const, decltype, auto

#ifndef LESSON_2_4_H#define LESSON_2_4_H#include extern const int ciExt;inline void print_ciExt(){ std::cout << ciExt << std::endl;}#endif // !LESSON_2_4_H#include "lesson_2_

2014-07-31 23:31:38 583

原创 c++ primer(第五版)笔记 第二章(3)复合类型

#includeusing std::cout;using std::endl;int main(){ //引用(reference),一个对象的别名,使用 & 定义,必须初始化 //一旦初始化完成,无法解绑定,因为所有操作都是在与之版定的对象上进行 //引用不是对象 //引用的类型要和与之绑定的对象严格匹配(有例外) int val = 10; int

2014-07-30 03:09:09 461

原创 c++ primer(第五版)笔记 第二章(2) 变量

#include#includeusing std::cout;using std::endl;int zero; //定义extern int i = 3; //定义extern int l; //声明extern int l; //声明,可以多次声明,但定义只能有一个extern int l; //声明int main(){ //数据类

2014-07-30 01:13:25 522

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除