由买买提看人间百态

topics

全部话题 - 话题: foo
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
A**********e
发帖数: 3102
1
来自主题: Linux版 - Samba 有些文件名不显
我这个是重新在 windows 底下 copy 进去就成了,是咋回事?
比如说,samba 下有个一 folder,名字叫 foo,下面有 f1, f2, f3 仨文件。mount 到
windows xp 本地的 Z:,在 explorer 里看,Z: 下面有 foo,但 foo 里面是空的。但
是,如果把同名的文件,比如说 f1,试图 copy 进 foo 里,系统就报错。
用 winscp 把 foo 里的文件 move 出来,然后在 explorer 下再 copy 回 Z:/foo 里去
,文件名就全显示了。
这个毛病的病根儿在哪里?
X****r
发帖数: 3557
2
来自主题: Programming版 - 大侠们救命, C++ operator new 问题
先忽略你重载的operator new,把基本概念搞清楚。
从语法上来讲,void*不能自动转换成Foo*,这个是乌龟的屁股,所以你编译通不过,
从语义上来讲,rbv只是返回一片内存,new不仅分配内存还调用构造函数,这个赋值就
不对。
如果你想在指定的内存位置构造一个对象,用placement new:
Foo *y = new (rbv()) Foo;
如果你想强行把这片空间作为一个Foo对象来看待,用cast:
Foo *y = (Foo *) rbv();
但是后者这样的话你使用y的时候什么都可能发生。
D****A
发帖数: 360
3
来自主题: Programming版 - 码工试题 (转载)
class Foo
{
....int a;
public:
....Foo(int a) : a(a) {}
....int IncA() { return a; }
};
class Bar : public Foo
{
... int b;
public:
....Bar(int x) : Foo(x), b(this->IncA()) {}
};
In the list after Foo is initialized, it is ok to invoke IncA via this->IncA
() which will be translated to Foo::IncA since IncA is not virtual.
In case IncA is virtual, I agree with you that a good compiler should forbit
using "this" to call any virtual function since at that time vtable is
perhaps not ready.
In the ca
d****p
发帖数: 685
4
来自主题: Programming版 - 看道c++题: brianbench
I think we are gonna start a tricky discussion :-)
The lifetime of a temporary is ended when the expression generating the
temporary is evaluated.
So,
Foo const& foo = static_cast(Foo()) will yield a dead reference,
pointing to destroyed object (the
foo). Isn't it a programming error?
So never explictly construct a reference to a temporary - doing so will
invalidate the object behind the
reference when the initialization statement completes.
The form DoSthForFoo(Foo()) is valid (supp
w*******a
发帖数: 21
5
来自主题: Programming版 - question about mock
很恶心, 公司要求写unit testing code.
class X
{
...
public:
void foo()
{
...
abc_.doSomething();
}
private :
ABC abc_; // created in constructor of X
Node * p;
}
1)如果我要测试class X 的 foo(), 但是 abc_ 并没有作为 passed in a parameter
in function foo(), how could i pass a mocked class ABC instance to
replace abc_?
2) 另外就是假若我测试 foo()的时候, foo() 的执行取决于 X class 前面执行已经建立的状态 state. 我测试的时候如何模拟这个状态的成立? 比如 X class has a linked list Node *p, when foo() is executed, the linked list should have
d****p
发帖数: 685
6
来自主题: Programming版 - class impl
Thanks - but that's why I am confused.
If its purpose is to decouple any units include-ing Foo.h and Foo's
actual implementation, the situation already justifies promoting Foo into
a higher level as abstract class such as IFoo.
So basically it is
abstract(IFoo) - semi abstract (Foo) - solid (Foo::Impl)
vs
abstract (IFoo) - abstract (IFoo) - solid (Foo).
Maybe I am missing sth but I deem the second concept is cleaner.
Hmm seems the 1st approach does have merit - its instan
N***m
发帖数: 4460
7
来自主题: Programming版 - c++小问题
effective c++上面的讲proxy class,给的例子只有轮廓,但没有具体实现。
我就练习一下。问题是
ostream& operator << (ostream& os, const Array2D & a)必须要const_cast,
不然编译不通过。我尝试把Array1D operator[](int pos)声明为const,也不行。
我哪个地方搞错了?还有typeid(T)返回的是i和3Foo,不是integer和Foo,
这个是不是和编译器有关?
/*
use of proxy class
*/
#include
#include
using namespace std;
// class Foo is some type for test Array2D later;
class Foo {
int val;
public:
Foo(){}
Foo(int i):val(i){}
friend ostream & operator<<(ostream& os, const Foo & b);
}
G*****7
发帖数: 1759
8
来自主题: Programming版 - 问个disable copy constructor的问题
not directly answering your question, but a c++11-compliant compiler such as
gcc/clang/icl has provided the syntax sugar of "= delete". that ought to
give you more diagonostic error messages wrt cp-ctor.
instead of
class foo
{
foo(const foo &);
}
you could do
class foo
{
foo(const foo &) = delete;
}
N******K
发帖数: 10202
9
我估计你喜欢 return shared_ptr 或者 把 shared_ptr 作为函数参数
比如这样的例子 http://stackoverflow.com/questions/395123/raii-and-smart-pointers-in-c
void setLog(const Foo & foo, const Bar & bar) {
shared_ptr file(new File("/path/to/file", File::append));
foo.setLogFile(file);
bar.setLogFile(file);
}
foo::setLogFile(shared_ptr input_file)
{ member_of_foo=input_file;
}
bar::setLogFile(shared_ptr input_file)
{ member_of_bar=input_file;
}
类的成员变量 也当做函数输出
比如 setLog 的输入是 const Foo & foo, con... 阅读全帖
S*A
发帖数: 7142
10
来自主题: Programming版 - C一个问题搞不懂
你这个理解不对。只有一次 dereference。
二维的下标只是用来计算转换的连续一维数组(内存)的 offset。
下标的 offset 计算本身不是 dereference.
我给你这个示范程序,注意看这里面的 array assign.
只用了一个 dereference。
======================
int a[5][6];
void foo(void)
{
a[1][2] = 1;
**a = 2;
}
======================
$ gcc -S -O2 multi.c
.file "multi.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movl $1, a+32(%rip) // 这里是 a[1][2] = 1
movl $2, a(... 阅读全帖
m*********a
发帖数: 3299
11
来自主题: Programming版 - 这二个在C++中有区别不?
Foo 是一个object
Foo &myFoo=*(new Foo());

Foo myFoo=*(new Foo());
myFoo都是Foo的一个reference吧?
m*********a
发帖数: 3299
12
来自主题: Programming版 - 这二个在C++中有区别不?
Foo 是一个object
Foo &myFoo=*(new Foo());

Foo myFoo=*(new Foo());
myFoo都是Foo的一个reference吧?
c********1
发帖数: 421
13
来自主题: Programming版 - C# 6.0 的视频,太猛了...
在没有精简写法之前
的“本来”也完全不止一种写法
比如
var foo = {}
if (bar != null) {
foo = bar
}
可以用
var foo = (bar == null)? {} : bar;
也可以用
var foo = null;
if (bar != null) {
foo = bar
}
else {
foo = {}
}
显然是精简写法最易读
v******y
发帖数: 84
14
来自主题: Programming版 - 问两个C++语法问题
设想传入一个literal string "C++",
foo("C++")
foo(const string &) 和foo(const string &&)都可以接受这个"C++",都不会copy
如果二个函数同时存在,会调用第二个
但是不能调用foo(string &),但是可以调用foo(string &&)同时没有copy
foo(string) 会接受调用,但是会copy
&&可以接受literal 和unnamed temporary object.
A*******e
发帖数: 2419
15
来自主题: Programming版 - 请教C++ call-by-ref & call-by-val的问题
用functor是更清楚,但本质问题是一样的。
struct GetFoo {
void operator()(Foo foo) {
v.emplace_back(std::move(foo));
}
vector v;
};
using Callback = std::function;
这里GetFoo可以当Callback用吗?
引入std::move之后,call-by-value和call-by-ref用法有区别了。只读时用ref,需要
复制时用value+move。但编译器似乎还是认为这是同一个函数,故有此疑惑。
S********t
发帖数: 3431
16
比如scala里:
class Foo {
abstract class Bar[A] (val id: String) {}
}
我在另外一个 Java project里想要 extends这Bar:
Foo foo = ...
Foo.Bar bar = foo.new Bar(foo, "id") {...}
可以这样做吗?我试了似乎是可以 compile,但 runtime总是说Bar的 constructor
NoSuchMethod...
请教下版上的scala-java高手,是不允许这样做,还是需要一些什么 trick吗?多谢!
具体的 background是在写一个 Java的 finagle-thrift service,可twitter
finagle全是用scala写的。。。想写个 request independent的 context extraction
就碰到这个问题了。。。
o**n
发帖数: 2130
17
Kotlin 和 Checked Exception
最近 JetBrains 的 Kotlin 语言忽然成了热门话题。国内小编们传言说,Kotlin 取代
了 Java,成为了 Android 的“钦定语言”,很多人听了之后热血沸腾。初学者们也开
始注意到 Kotlin,问出各种“傻问题”,很“功利”的问题,比如“现在学 Kotlin
是不是太早了一点?” 结果引起一些 Kotlin 老鸟们的鄙视。当然也有人来信,请求
我评价 Kotlin。
对于这种评价语言的请求,我一般都不予理睬的。作为一个专业的语言研究者,我的职
责不应该是去评价别人设计的语言。然而浏览了 Kotlin 的文档之后,我发现 Kotlin
的设计者误解了一个重要的问题——关于是否需要 checked exception。对于这个话题
我已经思考了很久,觉得有必要分享一下我对此的看法,避免误解的传播,所以我还是
决定写一篇文章。
可以说我这篇文章针对的是 checked exception,而不是 Kotlin,因为同样的问题也
存在于 C# 和其它一些语言。
冷静一下
在进入主题之前,我想先纠正一些人的误解,让他... 阅读全帖
i*o
发帖数: 149
18
来自主题: Unix版 - help on building shared object
To build a shared object( .so file),I used following commond:
gcc -fPIC -shared -o output.so input.c
and foo( ) is a function defined in input.c
In order to call foo, I did following in calling process:
void * handle = dlopen("output.so",RTLD_LAZY);
if((error=dlerror())!=NULL){
fputs(error,stderr);
exit(1);
}
foo = dlsym(handle,"foo");
foo()...
However, I got result:
./output.so: undefined symbol: foo
I am pretty sure the problem is from the shared object output.so which was not
S**I
发帖数: 15689
19
来自主题: JobHunting版 - C++ Q83: 这个const_cast什么意思?
As long as you don't try to modify a declared constant, it is fine. For
example:
void foo(int* p){
//do something with p, but do not change what p points to
}
int main (){
const int a = 2;
const int* b = &a;
foo(b); //error! foo expects int*, not const int*
int* c = const_cast(b);
foo(c); //this is OK
}
Many legacy C codes contain functions like foo, so it is necessary to use
const_cast in these cases.
Another example:
int main(){
int a = 2;
const int* b = &... 阅读全帖
l******d
发帖数: 530
20
来自主题: JobHunting版 - 如何判断char的赋值有没有溢出
考虑这个函数
void foo(char c){
...
}
如果用户传递个大于127的值给c,比如 foo(128),在foo里c是溢出的,得到的值是-
128。如果用户在调用foo前判断传给c的值是不是大于127或小于-128很容易,有没有办
法在foo里检测传给c的值是溢出的呢,就是说,不依赖于函数的用户去检测溢出。
k*******t
发帖数: 202
21
来自主题: JobHunting版 - 问个java List的问题
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Foo {
String name;
int number;

List friends;
public boolean equals(Object obj)
{
System.out.println(friends);
System.out.println(test.friends);
System.out.println(test.name);
System.out.println(this.name);

return number == test.number
&& (name == test.name
|| (name != null && name.equals(... 阅读全帖
n*****g
发帖数: 178
22
题目是CC150第五版16.5题,题目是这样的:
Suppose we have the following code:
public class Foo {
public Foo() { . . . }
public void first() { ... }
public void second() { ... }
public void thirdQ { ... }
The same instance of Foo will be passed to three different threads. ThreadA
will call first, threads will call second, and threadC will call third.
Design a mechanism to ensure that first is called before second and second
is called before third.
这要换成C语言来问的话,是不是等同于这样问:一个foo函数,确保foo先被first调用
,然后再被second和third调用(f... 阅读全帖
w**********o
发帖数: 140
23
来自主题: JobHunting版 - 请教一个c的概念题
1. save your code in foo.c
void foo(int *p, int *q)
{
while (p ...
}
2. gcc -S -o foo.s foo.c
3. vim foo.s
4. read the assembly.
or just use this if you are lazy: http://assembly.ynh.io/
c****a
发帖数: 50
24
题目有点长,求大牛赐一个漂亮点的解法
面试要求可以在eclipse等工具下完成,可以上网用google等
ProgA
System Dependencies
Components of computer systems often have dependencies--other components
that must be installed before they will function properly. These
dependencies are frequently shared by multiple components. For example, both
the TELNET client program and the FTP client program require that the TCP/
IP networking software be installed before they can operate. If you install
TCP/IP and the TELNET client program, and later decide ... 阅读全帖
x*****0
发帖数: 452
25
来自主题: JobHunting版 - indeed 面试题
实现如下两种操作。
// addMapping("/foo/bar/x", "XController")
// addMapping("/foo/bar/z", "ZController")
// addMapping("/foo/baz", "BazController");
//getMapping("/foo/bar/x") -> ["XController"]
//getMapping("/foo/bar") -> ["XController", "ZController"]
public void addMapping(String path, String destination) {
//candidate TODO

}
public List getMapping(String path) {
//candidate TODO

}
x*****0
发帖数: 452
26
来自主题: JobHunting版 - indeed 面试题
实现如下两种操作。
// addMapping("/foo/bar/x", "XController")
// addMapping("/foo/bar/z", "ZController")
// addMapping("/foo/baz", "BazController");
//getMapping("/foo/bar/x") -> ["XController"]
//getMapping("/foo/bar") -> ["XController", "ZController"]
public void addMapping(String path, String destination) {
//candidate TODO

}
public List getMapping(String path) {
//candidate TODO

}
xt
发帖数: 17532
27
来自主题: Java版 - java数据库读取错误,请教

Don't you think I know this part of the story? Just in case you
do not understand the situation, or totally are ignorant of Oracle
JDBC, let me give you an example:
Create a table with field foo (CHAR32)
Use JDBC, insert a row with foo="hello"
Use JDBC, search the table with foo="hello", you get NOTHING back
Use JDBC, search the table with foo="hello" plus 26 spaces you get
a row back.
Use SQL Plus, search the table with foo="hello" you get the record
back
Obviously this is a very small test ca
o*******a
发帖数: 46
28
来自主题: Java版 - a synchonized problem!
public class Foo{
private static Foo mInstance;

public static Foo getInstance(){
if(mInstance == null){
synchronized(Foo.class){
if(mInstance == null){
mInstance = new Foo();
}
}
}
return mInstance;
}
}
Will this work in all environments? If not, under what condition will this
fail? ?
t***a
发帖数: 416
29
c++中
void foo(){
A a; //a在stack中,如果foo结束,a就销毁
A* a = new A; //foo结束,a指向的东西还在, 所以你需要delete a在其他什么地方
}
java中
void foo(){
A a = new A(); //a只是个reference, 在stack中,a指向的instance在heap中。如
果foo结束了,销毁的只是这个ref。如果再没有任何ref指向new A()出来的这个
instance, GC会在以后的某个时间自动销毁instance
}
所以其实没啥大差别。。。。。一个自动档,一个手动挡。。。

的.
s*********d
发帖数: 165
30
来自主题: Linux版 - 怎样用vim编译java
最近发现一个不错的vimrc
http://vim.spf13.com
现在一旦保存java文件:w,vim就会自动编译。不过很多java classes都事packaged的
,比如说
File directory:
~/proj/bin/com/example/package/foo.class
~/proj/bin/com/example/package/foo1.class
~/proj/src/com/example/package/foo.java
~/proj/src/com/example/package/foo1.java
Class foo need to use class foo1. Using terminal, here is how I can compile
cd ~/proj/bin
javac -d ./ ../src/com/example/package/foo.java
(1, $CLASSPATH = "~/proj/bin", 2, this way only works when we cd to ~proj/
bin. )
With s... 阅读全帖
e******r
发帖数: 220
31
来自主题: Programming版 - ask a C++ inheritance question

那要不要在FooToo 和Bar定义的时候也加上virtual, 换句话说, 下面的是不是
每个inherutance都要加上virtual? 我试了一下, 好象virtual inheritance的个数决定下面的例子的结果.

#include
class Foo
{
public:
Foo(){std::cout<<"Foo";}
};
class Bar: Foo
{
public:
Bar(){std::cout<<"Bar";}
};
class FooToo:virtual Foo
{
public:
FooToo(){std::cout<<"FooToo";}
};
class FooTooBar:virtual FooToo, virtual Bar{
public:
FooTooBar(){std::cout<<"FooTooBar";}
};
int main()
{
FooTooBar a;
return 0;
}
q*****g
发帖数: 1568
32
来自主题: Programming版 - Python, import/global
我知道在Python里头,global statement是一个module里头的global变量。
所以如果我有一个文件叫做module1.py, 里头有这么一个函数:
def func1():
global foo
print foo
然后在我的主程序里头用:
from module1 import func1
foo = "bar"
func1(foo)
肯定会出错。因为module1里头的func1根本看不到主程序的foo。
那么,有什么办法让module1里的函数看到主程序的变量呢?还是根本不可能?
F*****n
发帖数: 1552
33
来自主题: Programming版 - C++疑问
关于private里面定义virtual function的两个问题。对于以下程序,
1. a->foo()编译不能通过,说是访问了private member.这是不是表明private里面定
义virtual function毫无意义啊?
2. 既然不被允许访问private member, 这说明complier还是把*a当作B的Object. 然而
a->foo2()也不能通过,因为A没有这个function。为什么作为B的Object连自己public
的member都不能访问呢?
#include
using namespace std;
class A {
int a;
virtual void foo(){
cout << "A:foo" << endl;
}
};
class B:public A{
int b;
void foo(){
cout << "B:foo" << endl;
}
public:
void foo2(){
cout <<
c****y
发帖数: 24
34
来自主题: Programming版 - C++疑问
1. A::foo()是private function, B::foo()也是,需要改成public
2. a 是个A*, A中没有foo2(),不能通过 a 访问 B中 foo2()

关于private里面定义virtual function的两个问题。对于以下程序,
1. a->foo()编译不能通过,说是访问了private member.这是不是表明private里面定
义virtual function毫无意义啊?
2. 既然不被允许访问private member, 这说明complier还是把*a当作B的Object. 然而
a->foo2()也不能通过,因为A没有这个function。为什么作为B的Object连自己public
的member都不能访问呢?
#include
using namespace std;
class A {
int a;
virtual void foo(){
cout << "A:foo" << endl;
}
};
class B:public A{
int b;
d****p
发帖数: 685
35
来自主题: Programming版 - 码工试题 (转载)
hmm.. At that time, this is firmly valid (though not property initialized)
so I guess compiler will allow dereferencing this in the derived class's
ctor's initialization list; it is however programmer's responsibility to
make sure it is used properly.
Consider the following legitimate example:
class Foo
{
....int a;
public:
....Foo(int a) : a(a) {}
....int IncA() { return a; }
};
class Bar : public Foo
{
... int b;
public:
....Bar(int x) : Foo(x), b(this->IncA()) {}
};
In the list after Foo is i
B*****t
发帖数: 335
36
来自主题: Programming版 - 一个c++ constructor的问题, thanks
找出下面的程序的毛病!
class Foo {
public:
Foo(int x, int y){
xx = x, yy = y;
}
Foo(int x) {
new(this) Foo(x*2, x*3);
}
int xx,yy;
};
int main() {
Foo fo(3);
cout< cout< return 0;
}
w*****3
发帖数: 101
37
来自主题: Programming版 - vector在constructor里初始化
class Foo{
public:
Foo(int capacity);
....
private:
vector _stack;
....
};//class Foo
Foo(int capacity){ //Foo1
//wrong, _stack still empty outside the constructor scope
vector_stack(capacity);
}
Foo(int capacity){ //Foo2
//right, _stack initialized
_stack = vector(capacity;
}
Questions:
why vector_stack(capacity); in the constructor Foo1 doesn't work
Thanks
z****e
发帖数: 2024
38
来自主题: Programming版 - 看道c++题: brianbench
add this to the code
~Foo(){
cout<<"Foo::~Foo()"< }
output
Foo::~Foo()
1
so the result should be "undefined" when const refer to a tmp.
i now agree with you about this point.
thanks for digging this out.
l******u
发帖数: 1174
39
来自主题: Programming版 - Interview question: is the following code OK?
Agreed. Seems to me the author tried to kill 2 birds with one stone (2 birds
being life-cycle of Foo objects, and map membership of Foo objects), and
got himself/herself in trouble. If it were me, I would write separate code
for managing the map instead of depending on the constructor/destructor of
Foo -- I would write some wrapper code on top of the Foo class to manage the
membership of the Foo objects in the map.
c***k
发帖数: 1589
40
来自主题: Programming版 - C pre-compiling 如何用macro替换括号?
比方说想把所有的foo(3),替换成bar,但是foo(1), foo(2), foo(4), .... foo(x)都
不变
H****S
发帖数: 1359
41
来自主题: Programming版 - 判断Python程序员水平的一个试题
很简单,写一个Python Singleton Class。
类似于这样的不算,
class foo(object):
_instance = None
@classmethod
def get_instance(cls, *args, **kargs):
if cls._instance is None:
cls._instance = foo(*args, **kargs)
return cls._instance
...
因为用户还是可以直接调用foo(*args, **kargs)来创建新的object,而Python是没
有private/protected这样的access modifier的。
我的答案,
class foo(object):
_instance = None
def _initialize(self, *args, **kargs):
# do your initialization here
def __new__(cls, *args, **karg... 阅读全帖
l**********n
发帖数: 8443
42
来自主题: Programming版 - 问个 enum{}的问题 谢谢 (转载)
enum Foo { BAR, BAZ };
enum Foo testFunc(void)
{
return BAR;
}
Or, with a typedef:
typedef enum Foo { BAR, BAZ } Foo;
Foo testFunc(void)
{
return BAR;
}
c*****e
发帖数: 3226
43
来自主题: Programming版 - 最近学了一下 Go
再聊聊这个 pointer与 interface 的傻逼关系。
type Foo struct {}
func (f Foo) xyz1() ..
func (f *Foo) abc1()...
type InterfaceXyz interface{
xyz1()
}
type InterfaceAbc interface{
abc1()
}
func Add(a InterfaceXyz)
func Dec(b InterfaceAbc)
var k Foo
Add(k) --> OK
Dec(k) ---> not OK
g:=new(Foo)
Add(g) ---> ok
Dec(g) --> OK
所以一个 object 是否实现了一个 interface 取决于你用的是 value 还是 pointer.
有病而且病的不轻!

要。
zuo
s******u
发帖数: 501
44
来自主题: Programming版 - C++ most vexing parse到底怎么回事?
通常如果把函数指针func作为函数foo的一个参数的话,可以这么写
int foo( int(*func)() )
{
return func();
}
然后作为函数指针,加不加这个*是没有区别的,所以简化成
int foo(int(func)()) { ... }
再接下来,函数的参数可以只给类型不给命名,表示我在函数内部不会使用到这个参数
,继续简化成
int foo(int()()) { ... }
因为没有函数变量的名字,所以第二个括号是可有可无的
int foo(int()) { ... }
把第一个int换成你这里的A,把第二个int换成你这里的B于是就有了
A a(B());
当然就是一个函数声明了
p******a
发帖数: 6
45
【 以下文字转载自 Linux 讨论区,原文如下 】
发信人: patapata (SF<->LA), 信区: Linux
标 题: 再问一个shared library的问题
发信站: The unknown SPACE (Sun Aug 27 13:15:45 2000), 转信
假定我要用到两个shared library库, liba.so 和 libx.so,liba.so又调
用libb.so里的函数,同样libx.so要调用liby.so里的函数,问题是如果
libb.so和liby.so里都定义了同样的函数,e.g. foo(),但是功能却不完
全一样,我该怎样做,才能让从liba.so里call foo()时调用的是libb.so
里定义的foo(),而从libx.so里call foo()时调用的是liby.so里定义的
foo()呢?
c*******h
发帖数: 1096
46
来自主题: Computation版 - 问个matlab function handle的问题
我有一个函数 func(x, para),要将它作为参数传给另外一个函数 foo
例如 foo( @(x)func(x,para), y, z )
那么 foo 函数应该怎么定义?
如果写成
function ret = foo( @(x)func(x,para), y, z )
那样是语法出错的
如果写成
function ret = foo( func, y, z )
那样又不能将 para 传进去
应该怎么写呢?
i***s
发帖数: 39120
47
铁达尼号3D版本问世,有关这艘「海上凡尔赛宫」的一切,又被大家从历史的尘封中挖了出来。历史资料显示,当年铁达尼号上共有8名中国人,在船沉没之后一共有6人存,但他们能够活命,全都是利用非常不光彩、甚至可形容是卑劣的手段。
1912年4月10日,铁达尼号缓缓的从英国南安普顿港口驶出,为人类海洋科技发展写下新里程碑。这艘船上共有2223名乘客,其中有8名是中国人,他们用大约56块英镑的价格,和电影里头男主角杰克(李奥纳多饰演)一样,买到了三等舱的船票。
经营铁达尼号的白星公司,当时有登记所有乘客的姓名。这8个中国人的名字分别为,Fang Lang、Lee Bing、Ali Lam、Chang Chip、Choong Foo、Lee Ling、Ling Lee和Len Lam。但由于时间长久,最后只能确认其中3人叫钟捷、李炳、炳新。
电影《铁达尼号》里头,住在三等舱的穷小子杰克,可以在各甲板自由进出,但现实情况不然,当时西方社会有严重的阶级制度,想上甲板与「萝斯」(凯特温丝蕾饰演)飞翔,必须穿越1个楼梯通道,但通道有铁门紧闭,出入受到管制。
报导指出,当时就算有钱人也不一定能买到头等舱船票。因... 阅读全帖
B******y
发帖数: 110
48

无聊地跟一贴。
泰坦尼克上的确有8个来自香港的华人水手,不过不是泰坦尼克的水手,
而是Donaldson Line的水手。8人在英国谋生,因为煤矿工人罢工的影
响,找不到船干活,于是乘泰坦尼克到纽约加入另一艘船。在泰坦尼
克上只能算是乘客。
8个华人都买的是三等舱票。名字如下:Choong Foo, Lee Bing, Ali
Lam, Chang Chip, Lee Ling, Ling Hee, Len Lam and Fang Lang。
http://www.titanic-titanic.com/choong_foo.shtml 说法,
Choong Foo是死于海难,而且尸骨无存。 不仅如此,8个华人中就
Lee Bing幸运存活。 他先上Lifeboat Collapsible C,后来再转到
Lifeboat 13。 如果titanic-titanic.com上的信息准确的话,生存率
不过1/8,而且他们还都是水手。
另一方面,按 http://www.encyclopedia-titanica.org 的说法,只有
Len Lam 和 Lee Ling丧生,而其... 阅读全帖
g********d
发帖数: 19244
49
☆─────────────────────────────────────☆
yjacket (yjacket) 于 (Wed Apr 10 22:50:02 2013, 美东) 提到:
一个小时前差一点在高速上撞死。之后到现在吓的胃和肚子痛的厉害。现在感觉魂魄回
来了一点,赶紧写出来。请大家帮我分析一下到底出了什莫问题?不敢给劳工打电话,
肯定要被骂死,而且还不会有客观意见。
背景介绍,中年女,来美国自学的开车到现在十年有余。上下班开的toyato camry.从
来没有出过什莫车祸。本人开车还是非常谨慎小心的。
因为工作原因要经常一个人出差。去过不少地方,所以也租过各种各样的车开过。
这次是到san antonio.结果租车公司给了一个两门的mustang小跑车。当时就觉得不爽
。但是就我一个人,而且不知道怎末有个印象,就是跑车抓地性能好。所以就从了。
今天从南边开回down town,上37号高速之后,有4条车道。我从最右边往左换道。下午
6点半左右,天还很亮,也没有下雨。周围有一些车,但还不是很拥挤。大家的车速在
60~65迈。如果超车,就大概70迈左右。而且都是直... 阅读全帖
s***c
发帖数: 50
50
来自主题: Classified版 - G家onsite面经
刚从G家onsite归来。新鲜面经奉上。
总共5轮,4轮technical interview, 一个thesis discussion。在technical里,有编
程题,有open design。我记得的问题有:
1. 编程题:一堆字符串。找longest common prefix。
我的方法就是找最短的字符串,对它的每个字符,逐个与其他字符串对应位置比较。(
求更好方法)
2. open question: 一堆文件,size差别极大( from KB to many GB). 找出所有内
容相同的文件。
3. 编程题: 有一个observer 类,监视另一个类foo 的成员变量的值,每当那个值被
修改,就要调用 该observer.updated() 方法。需要实现 foo.registerObserver(ob)
, foo.unregisterObserver( ob ), foo.changeValue( newvalue ). 要考虑thread
safe.
就是在register时把所有observer 链接到一个list里。在changeValue... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)