再问两个C++问题# Programming - 葵花宝典
g*s
1 楼
1.这个代码输出为何是0 1 10 2 4,而不是0 1 10 3 4?
#include
#include
#include
int main(){
std::vector v;
for (int i=0; i<5; i++){
v.push_back(i);
}
v.erase(std::find(v.rbegin(), v.rend(), 2).base());
v.insert(std::find(v.rbegin(), v.rend(), 1).base(), 10);
std::copy(v.begin(), v.end(), std::ostream_iterator(std::cout, " ")
);
return 0;
}
2. 这段代码里为何String s1('a')和String s1='a'不等价?
class String{
public:
explicit String(char c, int
#include
#include
#include
int main(){
std::vector
for (int i=0; i<5; i++){
v.push_back(i);
}
v.erase(std::find(v.rbegin(), v.rend(), 2).base());
v.insert(std::find(v.rbegin(), v.rend(), 1).base(), 10);
std::copy(v.begin(), v.end(), std::ostream_iterator
);
return 0;
}
2. 这段代码里为何String s1('a')和String s1='a'不等价?
class String{
public:
explicit String(char c, int