由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++ interview programming exercise
相关主题
ask a C++ inheritance questionC++ interview questions help
Nested classes inside one class (C++)经典C++问题求助
关于构造函数的一道测试题 (转载)find bugs of c++ codes
问个 enum{}的问题 谢谢 (转载)大侠们救命, C++ operator new 问题
Java里面能 extends Scala object的abstract inner class吗?码工试题 (转载)
class implQuestion about name resolution in C++
Why oop is bad?java main的疑问
三个C syntax 弱问题有没有办法让一个类的变量只读,不是const?
相关话题的讨论汇总
话题: class话题: c++话题: bar话题: foo话题: respond
进入Programming版参与讨论
1 (共1页)
h****4
发帖数: 39
1
本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位.
Using C++ write a solution to solve the following:
Class Foo performs an action that Class Bar needs to respond to. Class Foo
and Class Bar have no knowledge of each other. Write a system that will
allow Class Bar to respond to actions from Class Foo while preserving the
decoupled nature of both classes. The solution needs to be scalable and
extensible so that other classes can produce and respond to actions from any
other class.
· Must be written in C++
·
a****l
发帖数: 8211
2
出这种问题的人太搞笑了.你就这么回答:你是Bar,我是Foo,如果Bar能知道Foo做了什么
action大家又是完全隔离的no knowledge of each other,那么你不用我说就应该知道
我什么时候回答出了你的这个问题还知道我的答案是怎么样的.

any

【在 h****4 的大作中提到】
: 本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位.
: Using C++ write a solution to solve the following:
: Class Foo performs an action that Class Bar needs to respond to. Class Foo
: and Class Bar have no knowledge of each other. Write a system that will
: allow Class Bar to respond to actions from Class Foo while preserving the
: decoupled nature of both classes. The solution needs to be scalable and
: extensible so that other classes can produce and respond to actions from any
: other class.
: · Must be written in C++
: ·

m*****e
发帖数: 4193
3
You just need an adaptor class A that links the two.
A registers with Foo and responds to its action
Bar registers with A and responds to its action
In A's responder, it calls Bar's responder

any

【在 h****4 的大作中提到】
: 本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位.
: Using C++ write a solution to solve the following:
: Class Foo performs an action that Class Bar needs to respond to. Class Foo
: and Class Bar have no knowledge of each other. Write a system that will
: allow Class Bar to respond to actions from Class Foo while preserving the
: decoupled nature of both classes. The solution needs to be scalable and
: extensible so that other classes can produce and respond to actions from any
: other class.
: · Must be written in C++
: ·

c*****t
发帖数: 1879
4
For pure OO method, google "Inversion of Control" and
"Dependency Injection". Usually that's what people asks.
It is also possible to use C++ template, which is based on template
pattern, which is helped by the C++ compiler.

any

【在 h****4 的大作中提到】
: 本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位.
: Using C++ write a solution to solve the following:
: Class Foo performs an action that Class Bar needs to respond to. Class Foo
: and Class Bar have no knowledge of each other. Write a system that will
: allow Class Bar to respond to actions from Class Foo while preserving the
: decoupled nature of both classes. The solution needs to be scalable and
: extensible so that other classes can produce and respond to actions from any
: other class.
: · Must be written in C++
: ·

S*********g
发帖数: 5298
5
I think proxy/adaptor + observer can do the job too

【在 c*****t 的大作中提到】
: For pure OO method, google "Inversion of Control" and
: "Dependency Injection". Usually that's what people asks.
: It is also possible to use C++ template, which is based on template
: pattern, which is helped by the C++ compiler.
:
: any

1 (共1页)
进入Programming版参与讨论
相关主题
有没有办法让一个类的变量只读,不是const?Java里面能 extends Scala object的abstract inner class吗?
问一个C++的问题class impl
问个C++ 编译器临时变量的问题 (转载)Why oop is bad?
What does the default constructor do?三个C syntax 弱问题
ask a C++ inheritance questionC++ interview questions help
Nested classes inside one class (C++)经典C++问题求助
关于构造函数的一道测试题 (转载)find bugs of c++ codes
问个 enum{}的问题 谢谢 (转载)大侠们救命, C++ operator new 问题
相关话题的讨论汇总
话题: class话题: c++话题: bar话题: foo话题: respond