由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - amazon的那道题目
相关主题
An example of strategy pattern这个C++程序的运行结果是什么
请教一个c的概念题请教C/C++小
one C++ question求教:这个程序为什么不能编译?
C++: what is the output? How to interpret it?c++疑难问题。。
C++问题C: what is the output?
新手问个C++(Thinking in C++ source code)Interview questions, Bloomberg
c++ 程序一问问个C++ virtual function的问题
问个面试题微软C++面试题
相关话题的讨论汇总
话题: chair话题: table话题: stuff话题: public话题: furniture
进入JobHunting版参与讨论
1 (共1页)
s*****r
发帖数: 773
1
看了网上的讨论, 关于amazon那道wood steel table chair furniture的题目
自己写了一个, 牛人帮我看看我是否写的有问题......
在我机器上编译通过, 运行成功.
#include
using namespace std;
class stuff {
public:
stuff() {}
virtual ~stuff() {}
virtual void info() = 0 ;
};
class table : public stuff {
public:
table() {}
~table() {}
void info() { cout<<"Table "< };
class chair : public stuff {
public:
chair(){}
~chair(){}
void info() {cout<<"Chair"<
m******9
发帖数: 968
2
我不是牛人,但是我觉得你的第一个方案写的有问题。
第2个方案是对的。
你的第2个方案写的就是一个bridge pattern
P**********0
发帖数: 412
3
为什么是bridge pattern,
不应该是decorator吗?
弱人问一下。。

【在 m******9 的大作中提到】
: 我不是牛人,但是我觉得你的第一个方案写的有问题。
: 第2个方案是对的。
: 你的第2个方案写的就是一个bridge pattern

s*****r
发帖数: 773
4
请问有啥问题,谢谢.

【在 m******9 的大作中提到】
: 我不是牛人,但是我觉得你的第一个方案写的有问题。
: 第2个方案是对的。
: 你的第2个方案写的就是一个bridge pattern

l*****a
发帖数: 14598
5
1)Is it better to use statements as below:
furniture *wood_table=new table();
furniture *steel_chair=new chair();
so that u can use polymorphism here.
2) can u use materials as parameter for ctr() of furniture
and remove SetMaterials method as below:
furniture *wood_table=new table(new wood());
furniture *steel_chair=new chair(new steel());

【在 s*****r 的大作中提到】
: 请问有啥问题,谢谢.
1 (共1页)
进入JobHunting版参与讨论
相关主题
微软C++面试题C++问题
C++继承问题新手问个C++(Thinking in C++ source code)
问个c++的问题c++ 程序一问
srand()的问题问个面试题
An example of strategy pattern这个C++程序的运行结果是什么
请教一个c的概念题请教C/C++小
one C++ question求教:这个程序为什么不能编译?
C++: what is the output? How to interpret it?c++疑难问题。。
相关话题的讨论汇总
话题: chair话题: table话题: stuff话题: public话题: furniture