由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 最新微软SDE II面试题
相关主题
微软C++面试题面试题
C++ object size一问C++ Q21: size of virtual table
c++ vs Java virtual 实现(Y家)问个硬件加OO的面试题
one C++ questionfacebook phone面试题
讨论一个OO问题几道MS面试题
2道算法题。 求教大家!新书《Coding Interviews: Questions, Analysis & Solutions》已经出版
Microsoft vs Vmware vs Ebay offer求建议今天的面试题
问几个跟C++有关的面试题[请教] C++ coding question
相关话题的讨论汇总
话题: public话题: var话题: class话题: void话题: var2
进入JobHunting版参与讨论
1 (共1页)
c*****e
发帖数: 737
1
1, class A {virtual void f();}
class B:public A {};
class C:public B {};
class D:public A, B {virtual void f();}
让你说明D的virutal table
2, class A
{public:
A(int v) {var = v;}
void f(){cout << var << endl;}
int var;
}
class B:public A
{
public:
public B(int v1, v2){var = v1; var2 = v2;}
void f()
{cout << var << "," << var2 << endl;}
int var, var2;
}
main()
{
B* pb = static_cast(new A(1);
pb->f();
}
问你编译/运行会不会出错,出啥错。
3, atoi写程序,要返回错误代码,并且处理溢出。
q********c
发帖数: 1774
2
Onsite or phone? They don't look like microsoft style question.Normally,
they would focus on data structures and algorithms. Which team ?
p*i
发帖数: 411
3
第一题的virtual table应该是啥样的?
我想的是
class D
vtable (A)
+0 D:f(); // (D*)->f() evaluates to this
vtable (B)
+0 A:f(); // (D*)->B::f() evaluates to this
(D*)->A::f() is ambiguous
第2题要么给A定义一个不带参数的ctor,要么在B的ctor中explicitly call A's ctor
还有最后static_cast(B)应该改成 static_cast(B*)
static_cast(B)(new A(1))会去找B的接受一个A*参数的ctor(不存在),而且返回的不是指针

【在 c*****e 的大作中提到】
: 1, class A {virtual void f();}
: class B:public A {};
: class C:public B {};
: class D:public A, B {virtual void f();}
: 让你说明D的virutal table
: 2, class A
: {public:
: A(int v) {var = v;}
: void f(){cout << var << endl;}
: int var;

1 (共1页)
进入JobHunting版参与讨论
相关主题
[请教] C++ coding question讨论一个OO问题
amazon的那道题目2道算法题。 求教大家!
Interview questions, BloombergMicrosoft vs Vmware vs Ebay offer求建议
C: what is the output?问几个跟C++有关的面试题
微软C++面试题面试题
C++ object size一问C++ Q21: size of virtual table
c++ vs Java virtual 实现(Y家)问个硬件加OO的面试题
one C++ questionfacebook phone面试题
相关话题的讨论汇总
话题: public话题: var话题: class话题: void话题: var2