![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++ primer学习笔记
文章平均质量分 63
cqnkxy
这个作者很懒,什么都没留下…
展开
-
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 · 256 阅读 · 0 评论 -
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 · 265 阅读 · 0 评论 -
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 · 305 阅读 · 0 评论 -
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 · 270 阅读 · 0 评论 -
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 · 242 阅读 · 0 评论 -
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 · 252 阅读 · 0 评论 -
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 · 584 阅读 · 0 评论 -
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 · 298 阅读 · 0 评论 -
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 · 325 阅读 · 0 评论 -
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 · 235 阅读 · 0 评论 -
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 · 262 阅读 · 0 评论 -
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 · 416 阅读 · 0 评论 -
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 · 236 阅读 · 0 评论 -
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 · 286 阅读 · 0 评论 -
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 · 219 阅读 · 0 评论 -
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 · 297 阅读 · 0 评论 -
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 · 459 阅读 · 0 评论