由买买提看人间百态

topics

全部话题 - 话题: foo
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
s****j
发帖数: 14
1
来自主题: Java版 - Re: jbuilder current working dir?
output is for the compiled class files. You also need to
set the source path in "source" tab. Include all paths you need.
One thing is, keep in mind about package hirachy, for example,
if you have a package like com.foo.pk1, you need to create the
same structure for you source files like:
d:\work\src\com\foo\pk1\*.java
then you source path should be d:\work\src, not d:\work\src\com\foo\pk1
You probably need another folder called d:\work\out
then when you compile. JB will create the same structur
m******t
发帖数: 2416
2
来自主题: Java版 - Stupid IBM JDK

Well then I didn't miss your point. So can you reduce this to something like:
boolean foo() { return true; }
if (!foo()) System.out.println("false");
boolean fooRes = foo();
if (fooRes) System.out.println("true");
xt
发帖数: 17532
3
来自主题: Java版 - java数据库读取错误,请教

Quit complaining about Sybase. If you like Oracle, you should try
this:
define a table with a field like "foo CHAR(32)"
then use your JDBC to insert a row, set foo to be "hello".
Then use Oracle JDBC driver to retrieve it, with foo='hello'
See what you get.
We have been using JConnect5 all the time, except before
2001. We never had any surprises like this. DB2 has some,
Oracle has some.
g*****g
发帖数: 34805
4
来自主题: Java版 - speaking of crappy code
我现在最烦的是这种代码
private int foo;
private void a() {
foo = ...;
}
private void b() {

... = foo;
}
一整个类的函数基本就没有传入传出参数。所有需要的地方都用类变量,
让我想起C时代喜欢用全局变量的。偏偏一个类动则2-3k行,不停地需要
回到头上去看定义。
还有那种util类,根本不需要也没有constructor,所有调用的地方都来个
new Blah().execute(),就是不肯写成静态函数。
g****y
发帖数: 436
5
来自主题: Java版 - 请问有没有generic的array
谢谢,我开始也是这样想的。但是后来我想,如果我expect一个int[][],结果来了一个
List[][],事情就不好办了。如果
void foo(Object[][] lala){

for(Object[] la : lala){
for(Object l : la){
System.out.println(l.toString());
}
}
}
我怎么才能在foo里面filter掉像List这样的输入呢? 不会是来一大堆 if吧。
f*******n
发帖数: 12623
6
来自主题: Java版 - 一道java题
如果anonymous class不明白就可以不用anonymous class咯。上面的和这个有名的
class一样:
class Foo extends Thread{
public Foo(Runnable r) {
super(r);
}
public void run(){
System.out.println(2);
}
};
Thread t = new Foo(r);
t.start();
现在看得懂了吗?
Y**G
发帖数: 1089
7
来自主题: Java版 - Java支持placement new吗?
C++:
BYTE[] buffer = new Buffer[1024];
FOO *foo1 = new &buffer[0] ();
FOO *foo2 = new &buffer[sizeof(FOO)] ();

C++这样用户可以接管对象的内存管理. Java中有何替代?
N**********d
发帖数: 9292
8
来自主题: Linux版 - 问个自动安装软件的问题
有个软件要用户一路输入各种路径,输入密码
怎么能写个脚本,让它在很多地方重复安装
例如
$ program
where is your foo software? /usr/foo
where is your bar software? /usr/bar
enter your password: test
retype: test
怎么写个包装,自动输入
/usr/foo
/usr/bar
test
test
f******e
发帖数: 582
9
Suppose I have the following C program under Linux. When I run the program,
how should I know where the function main() and Foo() are loaded in the
physical memory?
int main()
{
Foo();
exit(0);
}
Foo()
{
printf(“hello world\n”);
}
q*****g
发帖数: 1568
10
来自主题: Programming版 - 再来问个蠢问题
【 以下文字转载自 Linux 讨论区 】
发信人: qiuxing (球星), 信区: Linux
标 题: 再来问个蠢问题
发信站: BBS 未名空间站 (Tue Nov 1 16:58:34 2005), 转信
Windows下相对应于UNIX的 foo.so的文件是foo.dll,那么相对于foo.a的文件呢?
Windows下怎么写一个静态连接的库文件?然后假设这个文件和它的头文件叫做
bar.a bar.h,怎么把hello.o和bar.a连起来?
k**n
发帖数: 20
11
来自主题: Programming版 - 三个C syntax 弱问题
应该都是基本语法了
第一个,
#include
using std::cout;
using std::endl;
class Foo {};
class Bar{
public:
operator Foo() { //<- 这是什么?重载()不是这样的吧
return Foo(); //还有这个?
}
};
int main (int argc, char * const argv[]) {
...............
...................
}
第二个, preprocessor:
#define pair_type(t,u) struct pair##_t##_u //为什么要_t,_u?( 和pair##t##u 有什么不同?)(好像两种都能run)
#define pair_decl(t,u) pair_type(t,u) { \
t first; \
u second; \
}
pair_decl(int,int); //展开是什么?struct pairintint {int
h****e
发帖数: 2125
12
来自主题: Programming版 - An interesting C++ compile error
the compiler expects you to override virtual foo(int) method as well,
otherwise it's confused. just simply do in Derived:
"
virtual int foo(int i)
{
return Base::foo(i);
}
"

base
elegantly
T***B
发帖数: 137
13
来自主题: Programming版 - An interesting C++ compile error
I feel it's not natural for the method of the derived class to do nothing
but calling the Base::foo.
virtual int foo(int i)
{
return Base::foo(i);
}
n****g
发帖数: 58
14
来自主题: Programming版 - 关于构造函数的一道测试题 (转载)
class Bar: Foo {
public:
Bar():Foo(5){} // 先构造Foo的对象,编译器找不到没有参数的构造函数。在子
类的构造函数后面加上父类带参数的构造函数就行了
};
Bar objBar;
lz
发帖数: 23
15
来自主题: Programming版 - A C++ private member function problem
Hello,
I am confused by the following code.
class A{
private:
void init();
public:
void foo(A& a);
}
void A::foo(A& a)
{
a->init();
}
This code passes c++ compliling. My question is that init()
is a private function, how can that be called in foo()?
Thank you!
g*********s
发帖数: 1782
16
来自主题: Programming版 - xterm的title恢复问题 (转载)
【 以下文字转载自 Linux 讨论区 】
发信人: gandjmitbbs (Nothing), 信区: Linux
标 题: xterm的title恢复问题
发信站: BBS 未名空间站 (Wed Feb 27 19:33:00 2008)
用RedHat 企业版。每次开一个xterm我会给一个title,例如MyProject以便记忆。
如果在xterm里vi某个文件foo.c,我希望看到文件名,所以在.vimrc里加了set title
。这时vi foo.c的话xterm title就是foo.c。
但是从vi退出时,我希望title会回到原来的MyProject,但是实际上,显示的是环境变
量$PS1的内容,例如$PS1=[u@\h \w]\$,这时的xterm title就是user@host ~/
fullpath。
在网上搜索了一下也没找到答案。有谁知道啊?多谢了。
r*********r
发帖数: 3195
17
来自主题: Programming版 - boost::function 的 syntax 问题
搞定了, bool (int) 是 function 类型, 而不是 function pointer 类型.
下面的小程序中 T *t_ 如果换成了 T t_ 就不能编译.
#include
template
class foo {
T *t_;
public:
foo(T *t) : t_(t) {}
void call(int n) { std::cout << (*t_)(n) << std::endl; }
};
bool bar(int x) { return x == 0; }
int main()
{
foo f(&bar);
f.call(0);
return 0;
}
l**a
发帖数: 423
18
来自主题: Programming版 - A C++ inheritance question!
IA
^ ^
| |
| |
IB SA
^ ^
| |
SB
这个是典型的继承类问题。你既然在IA里面用 pure virtual, 你一定要implete.
SB 有两个路径引用IA, 这会产生2个IA 的 copy 编译会出错。
解决方法有2个,一个是你用 ::解决路径问题,例如你想通过IB 调用foo(),
IB::foo(), 或者SA::foo().
另一个办法你的code 已经有眉目了,就是用 virtual class 的方法。
class IB: public virtual IA{
k**f
发帖数: 372
19
来自主题: Programming版 - overriding operator<<

No, because when you do so, the left hand side operand is the object. In the
case of operator<<, the lhs operand is the ostream.
On the other hand, it can be implemented as a non-friend free standing
function, if the output operation do not need to use the private or
protected data members or functions.
Example:
class foo {
private:
int m;
public:
foo(int n)
int value() const { return m; }
};
ostream& operator<<(ostream& os, const foo& f)
{
return os << f.value();
}
b*******a
发帖数: 68
20
来自主题: Programming版 - 数组问题
函数参数里的数组如指针等价,即以下相同 (那个100没什么用用,直接忽略,一般别
这么写,没用,因为compiler/runtime不检查,而且confusing):
void foo(char *p)
void foo(char p[])
void foo(char p[100])
x*****n
发帖数: 1905
21
来自主题: Programming版 - C code参数传递出错可能的原因
今天有一点C程序出了很奇怪的问题。一个很简单的函数:
a.c:
float n;
void foo(float m)
{
printf("%f\n", m);
n = m;
}
b.c:
foo(1.0);
在f()运行的时候,打印出来的是"-0.0".当然问题出在一个比较大的系统里。看起来是
什么地方发生了memory corruption。我把foo()的定义放到b.c里就没有问题了。
不知道像这种情况应该where to look?
h****4
发帖数: 39
22
来自主题: Programming版 - C++ interview programming exercise
本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位.
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++
·
t****t
发帖数: 6806
23
来自主题: Programming版 - 大侠们救命, C++ operator new 问题
new Foo has type Foo*
void* has type void*
void* can't be (implicitly) cast to Foo*
h****b
发帖数: 157
24
来自主题: Programming版 - 问个template问题吧
template void foo(T opt1, C opt2){};
template void foo(C opt1, T opt2){};
template void foo(C opt1, T opt2){};
哪一行编译出错?谢了
z***e
发帖数: 5393
25
来自主题: Programming版 - 问问C++的diamond problem
被问到一个问题,关于C++的diamond problem,就是class A, 然后B和C都inherit A
,并override A里面的virtual method foo(),然后D inherit B和C
问在D里面怎么用A.foo()? 不准用A::foo()这种.
我败在这上面了...:(
d****i
发帖数: 4809
26
来自主题: Programming版 - C++的一个问题
怎么在一个函数中调用某个类的数组?比如下面:
class A
{
public:
DoSomething() {...}
};
int main()
{
A a[10];
foo(a);
}
void foo(A *a)
{
int i;
for(i=0;i<10;i++)
a[i].DoSomething();
}
编译会通不过,怎么改才能实现在foo()中的循环呢?
t****t
发帖数: 6806
27
来自主题: Programming版 - 出个题考考大家:)
把fb去掉再来, cdecl不接受参数名, 比如说
cdecl> explain char foo(char)
declare foo as function (char) returning char
cdecl> explain char foo(char x)
syntax error
所以
cdecl> explain char *(*ff(char *(*)()))()
declare ff as function (pointer to function returning pointer to char)
returning pointer to function returning pointer to char
t****t
发帖数: 6806
28
来自主题: Programming版 - Question about name resolution in C++
yes, i tried your original post on gcc-4.4 and it passed.
gcc-4.1 rejected it, but accepts ::A::Foo().

member function Foo, like ::A::Foo()
d****p
发帖数: 685
29
来自主题: Programming版 - c++ question
Not really. It is powerful tool for stuff like boost lib, but you can use in
routine work as well.
For example, you have a client which wants to call some functions against a
object (T). Normal OO approach is
that:
1. Define T as abstract function with virtual function foo()
2. Define several derived classes realizing T
3. Pass a T* to the client and call the function t->foo()
So the client function looks like
Bar(T* t) { t->foo(); }
Good but incur a virtual function call while increasing size o
p***o
发帖数: 1252
30
来自主题: Programming版 - Interview question: is the following code OK?
主动析构Foo没问题,因为 至少还有一个引用(就是你正在析构的这个),
所以map::erase只析构shared_ptr,不会回到~Foo里面。
但是如果程序结束的时候map不为空而且每个里面的对象只有一个引用
(就是map里这个),那么map析构的时候 可能 会有重入问题,具体取
决于map析构时的行为,就是说如果shared_ptr析构引起Foo析构的时候
key还能在map中找到,那么就会有问题。
d****p
发帖数: 685
31
来自主题: Programming版 - Interview question: is the following code OK?
Your answer is basically right - it depends on map implementation.
So it may cause bus error on VS/Windows or GCC/Mac but run fine on Solaris
or GCC/Linux.
What happened is:
1. after exiting main, the static map object is gonna be destructed
2. since one node in the map is a shared pointer of Foo, the shared pointer'
s ref count is decremented (to zero), and ~Foo called.
3. inside ~Foo, the erase tries to re-decrement the shared pointer's ref
count - since it is already 0, no further action (so
d****p
发帖数: 685
32
来自主题: Programming版 - class impl
I recently got confused about one thing.
Previously I have class design as:
class IFoo { ... } // abstract class
class Foo1 : public IFoo { ... }
class Foo2 : public IFoo { ... }
Recently all the code was modified by a colleague as:
class IFoo { ... }
class Foo1 { Impl *pImpl ... }
class Foo1::Impl { ... }
In short, the implementation was moved from Foo to Foo::impl, which
is an internal class.
What's the benefit of doing so? To me this is not nice since Foo is
suppose to be implementat
t***o
发帖数: 4265
33
来自主题: Programming版 - 如何优化这段C代码
看你的意思就是想提高代码复用。那就用函数吧。
//code
foo(i,j){
code...
...
}
//col first
col_first(){
for (i=0;i<10;i++)
for (j=0;j<5;j++)
foo(i,j);
}
//row first
row_first(){
for (j=0;j<5;j++)
for (i=0;i<10;i++)
foo(i,j);
}
//main program
if(flag==1) col_first();
elseif(flag==2) row_first();
d****p
发帖数: 685
34
来自主题: Programming版 - java main的疑问
So your point is make EACH java method callable from command line?
This is not doable.
Suppose you have a method
void foo(Foo f) where Foo is an object.
How can you provide argument f for invoking the method in command line? And
since you could not
provide it, why expose this method to command line for unnecessary fuss?
And your concept is really bad for performance: it needs the java runtime to
inteprete string in argument
list to suitable types for function lookup and value conversion and this
g*********s
发帖数: 1782
35
来自主题: Programming版 - in-class static member question
so if i define a class w/ static variable members in foo.h, i'll have to
create a foo.cpp file to keep the definitions of these static variables,
instead of put these definitions in foo.h?

fact, if
"remember
is "
is
initializer is
somewhere
A******g
发帖数: 612
36
来自主题: Programming版 - What does int & mean? C/C++ question
A C/C++ question, I know
int* foo(void) foo
will return a pointer to int type
how about
int &foo(void)
what does it return?
Thank a lot!
e****d
发帖数: 895
37
来自主题: Programming版 - which style do you prefer?
That's right. Should not return reference to local object.
But are the following two cases valid?
extern const vector & foo(); //return reference to local obj.
case 1,
vector v(foo());
case 2,
foo().size();
q*******i
发帖数: 353
38
Sorry I am a rookie, I malloc memory use the same pointer (*ptr) transmitted
by main function. after the memory has been allocated in foo(), does the
(*ptr) in main automatically associated with the memory?
Thanks
void foo( int *ptr)
{
//malloc a 2D array using ptr
}
int main()
{
int *ptr
foo(ptr);
}

memory
g**w
发帖数: 969
39
来自主题: Programming版 - c++里的函数可不可以是virtual+static
http://c2.com/cgi/wiki?VirtualStaticIdiom
class Foo
{
public:
Foo();
protected:
// Virtual static idiom <-- StaticCallback?()
virtual bool Callback();
private:
// Virtual static idiom --> Callback()
static bool StaticCallback?( void *pThis )
{
assert( pThis );
return ((Foo *)pThis)->Callback();
}
};
c********2
发帖数: 56
40
来自主题: Programming版 - c++面试问题
1)
class foo{
public:
foo(int i){}
};
class bar: virtual foo{
public:
bar(){}
};
bar b;
what's wrong with the above code
2)
class X{
public:
X& operator=(const X& rhs);
const X& operator+(const X&rhs) const;
const X& operator+(int m);
private:
int n;
};
int main(){
X a, b, c;
system("pause");
return 0;
}
which one is wrong?
a=c+5;
a=a=b+c;
(a=c+4)=b+2;
a=b+c;
b=a+1;
3)
template<> class Stack
{
public:
int push(char);
char pop();
};
what template<> signify in the... 阅读全帖
j********g
发帖数: 88
41
RVO:
std::string rvo()
{
return std::string("Foo");
}
NRVO:
std::string nrvo()
{
std::string foo("bar");
return foo;
}
e****r
发帖数: 581
42
来自主题: Programming版 - 请问c++里empty class的问题
class foo {};
foo a;
foo b;
如果没有这个字节,&a == &b
C***y
发帖数: 2546
43
来自主题: Programming版 - Question about type conversion (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: Chevy (Chevy), 信区: JobHunting
标 题: Question about type conversion
发信站: BBS 未名空间站 (Fri Apr 6 14:39:16 2012, 美东)
Got error C2664: 'foo' : cannot convert parameter 1 from 'B *' to 'A *&'
How can I handle it? Thanks!
class A
{
};
class B: public A
{
};
void foo( A*& a )
{
}
void bar( B*& b )
{
foo(b);
}
int main()
{
B* b = NULL;
bar( b);
return 0;
}
X****r
发帖数: 3557
44
来自主题: Programming版 - Question about type conversion (转载)
foo((A*&)b); would compile, but the program won't behavior
if you ever do anything to a inside foo.
foo((A*)b); wouldn't compile, because you can't bind a
temporary to a non-const reference.
t****t
发帖数: 6806
45
来自主题: Programming版 - Question about type conversion (转载)
动动脑子嘛, 比如说B是A的子类, 那你可以把B*转换成A*, 所以你可以用B*来调用foo(
A*).
但是如果你是foo(A*&), 说明你不仅要把A*传进去, 还要把A*传出来. 那这个时候你用
B*来调用foo(A*&), 你要把A*转换成B*当然是不行的. 很简单的逻辑是不是?
p**o
发帖数: 3409
46
来自主题: Programming版 - python里的 lambda函数 有什么有点
跟一个普通函数差不多,只不过懒得起名,干脆叫lambda而已
没什么实质性好处
>>> def foo(x):
... return x + 1
...
>>> (lambda x: x + 1)(0)
1
>>> type(lambda x: x + 1)

>>> f = lambda x: x + 1
>>> g = foo
>>> f(1) == g(1)
True
>>> f.__name__
''
>>> g.__name__
'foo'
a***n
发帖数: 538
47
来自主题: Programming版 - int F::*x = &F::x是什么意思?
完整的code
https://gist.github.com/3343011
#include
int main()
{
struct F {
int x;
} foo, *foo_ptr = &foo;
int F::*x = &F::x;
foo.*x = 42;
printf("%d\n", foo_ptr->*x);
}
怎么也看不明白第8行啊
i*********n
发帖数: 58
48
Template function with scalar argument.
Compiler will optimize away the flag.
#include
using namespace std;
#define foo_plus foo
#define foo_minus foo
template
int foo(int a, int b) {
return plus ? (a + b) : (a - b);
}
int
main( int args, char *argv[] )
{
cout << foo_plus(5, 2) << endl;
cout << foo_minus(5, 2) << endl;
return 0;
}
a****l
发帖数: 8211
49
来自主题: Programming版 - 师傅们,C++概念题,弟子有礼了
这个快要看你怎么理解了.macro其实就是文本替换,所以你可能说定义了一个非常复杂
的函数或者过程写成foo(a,b,c),结果程序员就到处用foo(a,b,c),写起来非常方便,但
是实际的程序就是到处复制了替换后的foo(a,b,c),就是一段相同的程序被到处重复,这
样显然对编译的效率是不利的,对执行效率也可能会有影响.
r****o
发帖数: 1950
50
来自主题: Programming版 - 问个超简单的C问题
void foo()
{
int a=3;
}
int main()
{
foo();
return 0;
}
上面的常数3是不是先放在RODATA 数据段,在main()函数执行foo()的时候再从RODATA读
出来赋给stack上面的a变量。
这样,RODATA和stack都有一个地方存了这个3。
对吗?
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)