菱纱梦

导航

2014年11月8日 #

c++学习笔记——智能指针

摘要: 智能指针是为了便于管理动态内存,能够自动管理释放所指向的对象。智能指针共有三种:1、shared_ptr允许多个指针指向同一个对象;2、unique_ptr独占所指向的对象;3、weak_ptr是一个伴随类,它是一种弱引用,指向shared_ptr所管理的对象。这三种类型都定义在memory头文件中... 阅读全文

posted @ 2014-11-08 16:07 菱纱梦 阅读(223) 评论(0) 推荐(0) 编辑

2014年11月1日 #

c++学习笔记——字面值常量类

摘要: 字面值常量类:数据成员都是字面值类型的聚合类是字面值常量类。如果一个类不是聚合类,但是它符合一下要求,则它也是个字面值常量类: 1、数据成员都必须是字面值类型。 2、类必须至少含有一个constexpr构造函数。 3、如果一个数据成员含有类内初始值,则内置类型成员的初始值必须是一条常量表达式;或者如... 阅读全文

posted @ 2014-11-01 17:28 菱纱梦 阅读(311) 评论(0) 推荐(0) 编辑

c++学习笔记——聚合类

摘要: 聚合类定义:1、所有的成员都是public的。 2、没有定义任何构造函数。 3、没有类内初始值。 4、没有基类,也没有virtual函数。聚合类的初始化:我们可以提供一个花括号括起来的成员函数初始值列表,并用它初始化聚合类的数据成员: 例如:Data val={0,"Anna"}; 阅读全文

posted @ 2014-11-01 17:15 菱纱梦 阅读(548) 评论(0) 推荐(0) 编辑

2014年10月31日 #

c++学习笔记——构造函数

摘要: 构造函数定义:每个类都分别定义了它的对象被初始化的方式,类通过一个或几个特殊的成员函数来控制其对象的初始化过程,这些函数叫做构造函数。需要注意的几点:1:构造函数不能被声明为const的,当我们创建一个const对象时,直到构造函数完成初始化过程,对象才能真正取得其“常量”属性。因此构造函数在con... 阅读全文

posted @ 2014-10-31 21:47 菱纱梦 阅读(167) 评论(0) 推荐(0) 编辑

2014年10月21日 #

Maximal Rectangle

摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题意:在一个只有0、1的矩阵中找到一个面积最大的矩形,它内部所有的... 阅读全文

posted @ 2014-10-21 10:28 菱纱梦 阅读(172) 评论(0) 推荐(0) 编辑

2014年10月19日 #

C++中使用初始化列表比在构造函数中对成员变量赋值更高效

摘要: 这是在面试中遇到的一个问题,没有答出来,后来上网上查了一些资料,终于弄明白了:一、首先c++标准规定成员变量必须在调用构造函数前进行初始化(这一点很重要)二、如果我们在构造函数中对成员变量进行初始化,那么在进入构造函数之前,编译器会调用该成员变量的默认构造函数对成员变量进行初始化,当进入构造函数后,... 阅读全文

posted @ 2014-10-19 18:21 菱纱梦 阅读(413) 评论(0) 推荐(0) 编辑

2014年10月6日 #

Interleaving String

摘要: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", ret 阅读全文

posted @ 2014-10-06 10:16 菱纱梦 阅读(171) 评论(0) 推荐(0) 编辑

2014年10月5日 #

Binary Tree Maximum Path Sum

摘要: Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example:Given the below binary tree, Return 6. 阅读全文

posted @ 2014-10-05 20:59 菱纱梦 阅读(151) 评论(0) 推荐(0) 编辑

2014年10月4日 #

Word Break

摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl... 阅读全文

posted @ 2014-10-04 09:54 菱纱梦 阅读(179) 评论(0) 推荐(0) 编辑

2014年9月30日 #

Add Binary <leetcode>

摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".算法:模拟加法过程 1 class Solution { 2 public: 3 st... 阅读全文

posted @ 2014-09-30 10:42 菱纱梦 阅读(169) 评论(0) 推荐(0) 编辑