Cpp_Primer_Answers icon indicating copy to clipboard operation
Cpp_Primer_Answers copied to clipboard

《C++ Primer》第五版中文版习题答案

Results 60 Cpp_Primer_Answers issues
Sort by recently updated
recently updated
newest added

unique_copy 只能去除相邻的重复元素,如果在输入流中的序列不是有序的,那么unique_copy并不能完全去掉所有重复元素,所以在使用 unique_copy 之前要先排序 下面是我的代码,先全部拷贝到vector中,进行排序,再用unique_copy 拷贝到输出迭代器中 istream_iterator in_iter(cin), eof; ostream_iterator out_iter(cout, " "); vector v; copy(in_iter, eof, back_inserter(v)); sort(v.begin(), v.end()); unique_copy(v.cbegin(), v.cend(), out_iter); cout

p指向的值未定义吧,int *p = new int();是不是应该这样写?函数是bool类型也不应该return p吧

Exercise 6.24: Explain the behavior of the following function. If there are problems in the code, explain what they are and how you might fix them. ``` void print(const int...

fix typo "直达"内存耗尽

the correct output of regex index should be [2],[5],[7]

r1 - r4 都可以绑定const 引用

应该使用 `count_if` 而不是 `find_if`

(b) int *const p2 = &i2; 应该是不合法的。 我自己代码尝试了一下,会返回报错“error: cannot initialize a variable of type 'int *const' with an rvalue of type 'const int * “ 我理解的原因是由于i2是一个常量,而常亮的地址只能被存放在 指向常量的指针中。p2是一个常量指针,而非 指向常量的指针。