由买买提看人间百态

topics

全部话题 - 话题: someclass
1 (共1页)
s*i
发帖数: 388
1
【 以下文字转载自 Programming 讨论区 】
发信人: sci (ence), 信区: Programming
标 题: hadoop java 里面的SomeClass.class 是什么意思?
发信站: BBS 未名空间站 (Sat Feb 12 23:52:24 2011, 美东)
刚开始学习hadoop,看到如下代码
JobConf conf = new JobConf(WordCount.class);
查了下doc,定义如下:
JobConf(Class exampleClass)
Construct a map/reduce job configuration.
这种 WordCount.class 的函数参数究竟是传了什么进去 JobConf 的ctor?
是这个WordCount的binary ? 还是一个instance?还是String?
c**********e
发帖数: 2007
2
来自主题: JobHunting版 - C++ Q47: protected constructor (C39)
class someClass {
protected:
someClass() {}
someClass(const someClass&) {}
};
Why are the default and copy constructors declared as protected?
a) To ensure that instances of someClass can only be created by its subclass
b) To ensure that someClass can not be used as a base class
c) To ensure that instances of someClass cannot be copied.
d) To ensure that someClass cannot be instantiated on the stack
e) To ensure that instances of someClass cannot be created via new by a more
derived cl
l****n
发帖数: 727
3
来自主题: Programming版 - 问个问题--可能比较老
翻了jhq,没找到。
class someClass{
};
someClass *p=new someClass();
someClass *p=new someClass;
这2个语句有什么差别?
如果在someClass定义里已经定义了一个default constructor, 这2个语句有什么差别?
谢谢。
e****9
发帖数: 316
4
来自主题: JobHunting版 - 一道C++题
假设SomeClass有一个用户定义的默认构造函数,下面的两种调用有什么区别没有?
SomeClass *psc1 = new SomeClass();
SomeClass *psc2 = new SomeClass;
A*******1
发帖数: 985
5
来自主题: JobHunting版 - C++ Q47: protected constructor (C39)
Is that a Java question?
Then I think e is right.
you can not use protected constructor in a class that extends the
constructor's class. You have to call super() in inheriting class to invoke
the protected constructor in base class. for example:
Class B extends SomeClass
{
public B()
{
super();
}
somemethod()
{
SomeClass a = new SomeClass(); //wrong, unless SomeClass's constructor is
public
B b = new B(); // right
}
}
o****h
发帖数: 58
6
来自主题: Java版 - 这道题该走什么路

//要求做成一个method, 于是,偶这样
class Collie extends Dog{
public boolean isa(String className){ //需要全路径,如java.lang.Object
Collie param=new Collie();
try {
Class SomeClass = Class.forName(className);
// System.out.println(SomeClass);
Object obj = SomeClass.newInstance();
obj=(SomeClass)param; // 这里总是有问题呢,该怎么办 ???
return true;}
catch(Exception e){return false;}
}
}
另外一种方法倒是没问题,并且不必输入全路径,但好像烦了很多
class Collie extends Dog{
public boolean isa(String className){
b**o
发帖数: 16
7
来自主题: Java版 - 这道题该走什么路
SomeClass obj;
Object param;
try{
obj = (SomeClass) param;
System.out.println("Yes, it is a instance of SomeClass");
}catch(ClassCastException e){
System.out.println("No, it isn't.");
}
t****t
发帖数: 387
8
来自主题: JobHunting版 - c++ interview question
有一个static SomeClass xxx; 在main()以外
在SomeClass的constructor throw excption
static不是必须的
S*******0
发帖数: 198
9
来自主题: JobHunting版 - 贡献邮件面试题(Web Development)
Web development职位,不是很大的公司,先发邮件来做题,第一次碰到。
刚刚做完,过会发我的sample答案上来
1. Describe a deadlock. What causes it? What are the effects?
2. Consider class Car with method getMake() -> String. Write a function to
retrieve all Toyotas from the following data structure:
ArrayList cars
3. List the bugs/problems in the following code snippets:
a. select * from claim where diagnosis_id in (739.1) and where patient_id in
(select patient_id from patient where name is ‘SMITH’)
b.with a as (select * from claim)
s... 阅读全帖
S*******0
发帖数: 198
10
来自主题: JobHunting版 - 贡献邮件面试题(Web Development)
1. Deadlock describes a situation that two or more threads (processes) are
blocked forever, waiting for each other.
Causes: one thread needs to visit the resource that another thread is
possessing and vice versa.
Effects: If deadlock happens, the threads involved will hang there forever
in an undesired status. Deadlock should be avoided.
2.
public ArrayList getToyotas(ArrayList cars)
{
if(cars == null) return null;

ArrayList toyotas = new ArrayList();
for ... 阅读全帖
d*******n
发帖数: 524
11
那么int[]跟Integer[]可以mutually交换使用么?
如果有个method是这么定义的
public class SomeClass {
public void f(T[] array);
}
现在想对int[]使用SomeClass的f方法,怎么办?
(就像在C++里面那样,任何用template的地方既可以用class,也可以用int)
h*i
发帖数: 3446
12
来自主题: Programming版 - FP 之我见 (长)
你可以new无限多个record, (SomeRecord. 1), (SomeRecord. 2), ....
和 new SomeClass(1), new SomeClass(2), ....
一摸一样。
看来你一点也不懂record, 所以不知道这其实是一种有限制的class,其实在JVM里面就
是这么实现的。
这么叫“相对完备的集合”? nonsense again?
K******g
发帖数: 1870
13
来自主题: JobHunting版 - C++ Q47: protected constructor (C39)
好像都不太准确。相比较之下,选a吧。
但是someClass还是可以被created by a member or friend function.

subclass
c**t
发帖数: 2744
14
来自主题: DotNet版 - nHibernate mapping question
Can any nHibernate expert let me know what's wrong with the following? I
alwasy got Acccount.ListAttr as null; when do "foreach(var a in Account.
ListAttr)" I got invalid cast error: can't cast ISet to IList..
I have Account.hbm.xml as follows:
...




..
and Account.cs has:
public virtual ISet ListAttr {get; set; }
..
Also have SomeOtherClass.hbm.xml:
...
阅读全帖
m******t
发帖数: 2416
15
来自主题: Java版 - jmock ?? or any other mocking tools?
JMock is best used to mock interfaces, i.e., where you would inject
implementations
instead of hardcoded new SomeClass(). In the latter case the two classes
are probably
too tightly coupled to be tested separately anyway.
q*****g
发帖数: 72
16
the friend keyword is need when u want to overload operator<<
if the operator << is a member function, to output the class, we need
to write this:
Widget << cout; // Widget is a object of someclass
This is against common practise.
if use friend function, the function declaratoin will like this:
friend ostream& operator<< (ostream&, Widget&);
so we can write this:
cout << widget;
which is much clearer.
s*******e
发帖数: 28
17
来自主题: Programming版 - 一道面试怪题C++. (转载)
Reduce dependence between files.
Image if you don't use forward declaration, then you have to
use "#include SomeClass.h". It means you build up dependence between the
current file and the .h file. If .h is changed, then you have to recompile
the whole code.
a**a
发帖数: 416
18
In python 2.5,
from __future__ import with_statement
You can write a special objective working with the `with' statement, such as
with SomeClass() as obj:
## do you things here
## when leaving the current context normally or by exception,
## the obj's speciall method will be invoked and do the house
## cleaning job.
s*i
发帖数: 388
19
刚开始学习hadoop,看到如下代码
JobConf conf = new JobConf(WordCount.class);
查了下doc,定义如下:
JobConf(Class exampleClass)
Construct a map/reduce job configuration.
这种 WordCount.class 的函数参数究竟是传了什么进去 JobConf 的ctor?
是这个WordCount的binary ? 还是一个instance?还是String?
N***m
发帖数: 4460
20
不就是Class对象吗?
s*i
发帖数: 388
21
能具体点嘛?谢谢!
b*******s
发帖数: 5216
22
java.lang.Class
d********w
发帖数: 363
23
这就是java的反射机制,hadoop规定了mapreduce的框架,用户需要写自己的map,和
reduce类,(继承于MapReduceBase),在main函数中通过JobConf把用户类给注入进去
,在通过jobclient执行,也可以说是设计模式中的template模式
s*i
发帖数: 388
24
ok i c, it's reflection.
can i also use
Jobconf(Map.getClass())
??
r***e
发帖数: 2000
25
来自主题: Programming版 - confused over function signature C++
Now I am just totally confused here:
In a class, there are
class someclass() {
......
void foo();
void foo() const;
......
};
The question is: are these two function having the same
function signature? Or to rephrase, does 'const' change
the signature?
Is this obvious or I am just too tired?
1 (共1页)