由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Seattle版 - 大家来讨论一下c++吧
相关主题
中国EB2绿卡申请者看过来,形势危急! (zt)Initiative 1098
Microsoft Up 4% as CFO Talks Dividends with Goldmanincome tax没通过
有人看过这个房子吗,求意见Voters overwhelmingly reject income tax on wealthy
讨论一下organic 食品的性能价格比?A Brand New Badminton Club at North Kirkland!
强人藏蜜锅中,被警察发现逮捕New Badminton Club in North Kirkland Opened!
大家讨论一下国外的组合刀组好还是国内的一把大砍刀利索?gifted programs in public schools has been cut
讨论一下咱们的正骨师/chiropractor吧一个有意思的概念:Kolbe Index
BBC 羽毛球紧急求助(在线等): H1 or F1
相关话题的讨论汇总
话题: reduce话题: function话题: container话题: c++话题: typename
进入Seattle版参与讨论
1 (共1页)
i***0
发帖数: 8469
1
大家来讨论一下c++吧
Please answer the following c++ questions. Do not simply answer yes/no.
Always explain your assumptions and reasoning.
1. memset is sometimes used to initialize data in a constructor like the
example below. What is the benefit of initializing this way? Does it work
in this example? Does it work in general ? Is it a good idea in general?
class A {
public:
A();
private:
int a;
float f;
char str[35];
long *lp;
};
A::A()
{
memset(this, 0, sizeof(*this));
}
2. Your task is to implement the Reduce function using templates. The
Reduce fn applies a function of two arguments cumulatively to the items of
an STL container, from begin() to end(), so as to reduce the sequence to a
single value. For example, Reduce(, std::plus >()) should calculate ((((1+2)+3)+4)+5).
class NotEnoughElements {};
template
typename Container::value_type
Reduce(const Container& c, Function fn) throw (NotEnoughElements)
{
FILL OUT
}
3. Write a C++ program that would find and print the first longest
ascending or descending contiguous subsequence for a vector of integers. For
example, given a vector with
4, 2, 1, 2, 3, 4, 3, 5, 1, 2, 4, 6, 5
the program would find the underlined subsequence and print it.
4. You have a class that many libraries depend on. Now you need to modify
the class for one application. Which of the following changes require
recompiling all libraries before it is safe to build the application?
a. add a constructor
b. add a data member
c. change destructor into virtual
d. add an argument with default value to an existing member function
z********o
发帖数: 4284
2
1.有virtual function的时候是不是把vtable也给清掉了
2. STL忘记了
3.好像要Dynamic Programming
4. B,因为object size变了
1 (共1页)
进入Seattle版参与讨论
相关主题
紧急求助(在线等): H1 or F1强人藏蜜锅中,被警察发现逮捕
讨论一下一岁多孩子daycare的问题吧大家讨论一下国外的组合刀组好还是国内的一把大砍刀利索?
严肃认真地请教一下code review怎么做的问题讨论一下咱们的正骨师/chiropractor吧
Michelle Obama kicks off national drive April 12 to highligBBC 羽毛球
中国EB2绿卡申请者看过来,形势危急! (zt)Initiative 1098
Microsoft Up 4% as CFO Talks Dividends with Goldmanincome tax没通过
有人看过这个房子吗,求意见Voters overwhelmingly reject income tax on wealthy
讨论一下organic 食品的性能价格比?A Brand New Badminton Club at North Kirkland!
相关话题的讨论汇总
话题: reduce话题: function话题: container话题: c++话题: typename