- 博客(20)
- 资源 (5)
- 收藏
- 关注
原创 Something trivial. Type alias and const modifier
I found something interesting when I was writing a simple homework.struct Node{ string key; int value; Node *next; Node(const string &theKey, int theValue):key(theKey), va
2015-11-25 06:41:35
488
原创 Permutation & Combination
1.Permutation:1.1 RecursionPerm(vec, beg, end)1.When beg = end, print;2.Otherwise swap the first element denoted by beg with following elements, then do Perm(vec, beg + 1, end):for(i = beg;
2015-10-11 09:33:05
491
原创 A possible solution of MySQL workbench cannot connect to local host error on MAC
0.Make sure your mysql server is running.1.I will suppose your MySQL workbench was installed as default. Get into the terminal, type in:cd /usr/local/mysql/binThis will change your c
2015-09-23 12:28:28
475
原创 Minor issue about class define and the valid scope of scope operator
#algorithm.h#ifndef ALGORITHM_H#define ALGORITHM_H#include using std::cin; using std::cout; using std::endl;template class A{ struct B;public: A(){} ~A(){} B get();private: struct B {
2015-09-20 12:21:05
331
原创 Something about Binary search tree
1.Because we want to do the recursion, which means we have to supply parameters. It's not appropriate to leave the work to users. So we'll encapsulate the details into our private member functions.
2015-09-20 02:23:57
205
原创 My test program from learning "move constructor", "move assignment". For personal memo purpose.
#include #include /*When it comes to move assignment, we cannot just use std::swap(*this, rhs);It is because std::swap combines with three std::move commands: one is a moveconstructor, the other
2015-09-19 07:48:17
293
原创 A teeny tiny example about Function Objects
using std::cin; using std::cout; using std::endl;template const Object &findMax(const std::vector &arr, Comparator cmp){ int maxIndex = 0; for(int i = 1; i < arr.size(); ++i) if(cmp(arr[ max
2015-09-19 00:30:48
293
转载 Chaper 11. Associate Container
1.The associative containers do not support the sequential-container position-specific operations, suchaspush_frontor back. The associative containers do not support the co
2015-09-03 12:12:11
331
转载 Chapter 10. Generic Algorithms
1.With only a few exceptions, the algorithms operate over a range of elements. The algorithms that take an input range always use their first two parameters to denote that range.
2015-08-27 11:47:06
288
转载 Chapter 9 Sequential Containers
1.There are a few rules of thumb that apply to selecting which container to use: • Unless you have a reason to use another container, use avector.• If your program has lots of small el
2015-08-24 02:23:47
259
转载 7.6 Static Class Members
We can access a static member directly through the scope operator.in general, we may not initialize astaticmember inside the class. Instead, we must define and initialize each
2015-08-22 00:57:07
279
转载 7.1Defining Abstract Data Ty &7.3Additional Class Features &7.5
Objects that are const, and references or pointers toconst objects, maycall onlyconst member functions.
2015-08-19 13:17:42
609
原创 6.7Pointers to Functions
/*Something strange here is that if I drop the const qualifier in ‘func’, I am still able to push_back ‘add’ and the following functions to vector, yet it seems like those function also lose the cons
2015-08-19 13:16:59
279
转载 6.3Return Types and the return Statement &6.5Overloaded functions
Hence, the form of a function that returns a pointer to an array is: Type (*function(parameter_list))[dimension]C++11:trailing return type:auto func(int) -> int(*) [10];Using decltyp
2015-08-18 01:16:55
259
转载 5.4Iterative statement &6.2Argument passing
Because the condition is not evaluated until after the statement or block is executed,thedo while loop does not allow variable definitions inside the condition: do {// . . .mumble(foo);} while (i
2015-08-16 08:03:11
445
转载 4.1fundamentals
Whenwe apply decltype to an expression (other than a variable), the result is a referencetype if the expression yields an lvalue. As an example, assumep is an int*. Becausede
2015-08-13 01:25:05
265
转载 3.5Arrays & 3.6Multidimentional Arrays
int (*Parray)[10] = &arr; // Parray points to an array of ten intsint (&arrRef)[10] = arr; // arrRef refers to an array of ten intsint *(&arry)[10] = ptrs; // arry is a reference to an array of ten
2015-08-11 12:27:22
312
转载 3.2Library string Type
string s7 = "hello" + ", " + s2; // error: can't add string literals The statement is wrong because we can't add two string literals, as the "hello" + ", " does.the range for statementfor (declarat
2015-08-10 09:04:51
315
转载 2.4 const qualifier & 2.5 dealing with types
Terminology: const Reference is a Reference to constC++ programmers tend to abbreviate the phrase “reference to const” as“const reference.” This abbreviation makes sense—if you remember that iti
2015-08-08 13:26:34
283
转载 2.2&2.3 Variables
Variables defined outside any function body are initialized to zero.With one exception, which we cover in §6.1.1(p. 205), variables of built-in typedefined inside a function areuninitialized. Th
2015-08-03 17:29:29
354
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人