由买买提看人间百态

topics

全部话题 - 话题: obj1
(共0页)
P*****o
发帖数: 1077
1
obj2和obj1是同一個interface A的class的实例。
比如一个funcobj2.value = () => obj1.Value+1
在执行这个func时候,也就是get obj1的Value的时候obj1.Value
obj2 subscribe obj1
这样做的目的是,以后obj1的参数改变的时候,obj2可以得到通知,obj2的value也會
被(obj2.value = () => obj1.Value+1)更新,请问怎么实现?
説法一 :
據説,用interface A的concrete implementation,和obj1,obj2的可以怎麽private
通信?
求教!!
問題和這個人的類似,但是還是不知道怎麽做
http://stackoverflow.com/questions/26722900/c-sharp-how-to-access-instances-of-a-particular-type-that-are-used-in-funcint
大家有見過這樣的問題麽?
------------------------------------... 阅读全帖
P*****o
发帖数: 1077
2
obj2和obj1是同一個interface A的class的实例。
比如一个funcobj2.value = () => obj1.Value+1
在执行这个func时候,也就是get obj1的Value的时候obj1.Value
obj2 subscribe obj1
这样做的目的是,以后obj1的参数改变的时候,obj2可以得到通知,obj2的value也會
被(obj2.value = () => obj1.Value+1)更新,请问怎么实现?
説法一 :
據説,用interface A的concrete implementation,和obj1,obj2的可以怎麽private
通信?
求教!!
問題和這個人的類似,但是還是不知道怎麽做
http://stackoverflow.com/questions/26722900/c-sharp-how-to-access-instances-of-a-particular-type-that-are-used-in-funcint
大家有見過這樣的問題麽?
------------------------------------... 阅读全帖
l**********6
发帖数: 10
3
楼主 不太看得懂你发的,能不能详细解释一下
“比如一个funcobj2.value = () => obj1.Value+1” 中的 funcobj2 是什么?
“在执行这个func时候,也就是get obj1的Value的时候obj1.Value
obj2 subscribe obj1” 中 obj1.Value obj2 subscribe obj1 是什么意思?
d****n
发帖数: 1637
4
来自主题: Programming版 - 请教一个C++问题
typedef struct {
int * ip; //data array
size_t sz; // size of data array
} data_t ;
class class_t {
data_t data;
};
// in main
class_t obj1; obj2;
obj1.data.ip =(int *) malloc(100*sizeof(int));
obj1.data.sz=100;
//do the same for obj2
list lst;
lst.push_front(obj1);
lst.push_front(obj2);
...
list::iterator it=lst.begin()
while((it++)!=lst.end()){
int i;
for (i=0;idata.sz;++i)
printf("%d\n", it->data.ip[i]);
free( it->data.ip) ;
it->data.sz=0;
}
//no... 阅读全帖
z****e
发帖数: 54598
5
来自主题: Programming版 - oop还是跟fp是对立的
最简单例子,就不说场景
func1(Object1 obj1)
func2(Object2 obj2)
你觉得这两个是不是func1&obj1, func2&obj2两个紧密耦合了起来?
对比
obj1.func1
obj2.func2
其实是一回事
因为任何改动obj1的地方都会牵涉func1的改动
对吧?
对比
func1(Map map1)
func2(Map map2)
是不是就要更为松散呢?
这个时候你叠加func1&func2就很容易
当然一般这么理想是比较难做到的
多数时候还是这样
func1(Object obj)
func2(Object obj)
因为obj不变,所以func1(func2(obj))的叠加就很容易
但是如果obj在func1&func2中是不一样的
就变成紧耦合了,func和obj无法分离
所以fp不适合做这种一堆对象的场景,如果都是information
也就是map&list,就很容易了
沙发就在说这个,你回的一大通,我还以为你知道我在说啥呢
l*s
发帖数: 11
6
来自主题: Programming版 - Python的With語句嚇著我了
Python:
with obj1() as var1, obj2() as var2:
# some codes effective in the context of obj1 and obj2
# ...
C++:
{
var1 = obj1();
var2 = obj2();
// Some codes effective in the context of obj1 and obj2
// ...
}
有什麼區別嗎?

++
g*********s
发帖数: 1782
7
来自主题: Programming版 - FILE*的问题
如果单线程程序,两个对象共享一个FILE*指针会有问题吗?
比如每个对象都有个_fp私有成员,某个对象打开文件时做:
FILE* fp = fopen("foo.txt", r);
obj1->set_fp(fp);
obj2->set_fp(fp);
obj1->read_info(offset1);
// move file pointer to offset1 and read from file foo.txt.
obj2->read_info(offset2);
...
fclose(fp);
obj1->set_fp(NULL);
obj2->set_fp(NULL);
a*****e
发帖数: 1700
8
来自主题: Programming版 - oop还是跟fp是对立的
我觉得你要说的是:
func1(Object obj)
func2(Object obj)
这种写法,你在 func1 和 func2 的 body 里面只知道对象是 Object,从而不能谈论
更多。
换成 OO 的方式, obj->func1() obj->func2(),只需要知道 Object class 里面有
func1 和 func2 两个成员函数,而不需要知道 obj 具体是 Object class 还是它的
sub class。通过 sub class 来 overload method 可以实现更多功能。
这是你的意思,对不对?
这种 OO 里面的做法换成用 Haskell:
class ObjectClass a where
func1 :: a -> ...
func2 :: a -> ...
type ObjectType1 = ...
type ObjectType2 = ...
instance ObjectClass ObjectType1 where
func1 = ...
func2 = ...
instance ObjectC... 阅读全帖
j*******e
发帖数: 674
9
来自主题: Programming版 - C++ class template specialization question
By looking at the following code, I am confused by line 3.
Line 3 is not a special case of the base template, it is more like a "class
overload".But it can be compiled successfully.
The obj1 in line 7 is defined acorrding to line 3, but failed to compile.
How come?
=========================
template class Bar{}; //Base template
template class Bar{}; // Specialization, which is good
template class Bar阅读全帖
k***x
发帖数: 6799
10
用数学语言来说的话,两者之间争论的区别在于优化问题的约束不同。
传统优化问题
minimize obj1: 1/4 quarter time
obj2: 0-60mph time
s.t. rpm at any time <= red line
现在豪车柴油党关心的是解决这个新问题:
minimize obj1: 1/4 quarter time
obj2: 0-60mph time
s.t. rpm at any time <= 2000
G*****m
发帖数: 5395
11
2000哥能看明白吗?

用数学语言来说的话,两者之间争论的区别在于优化问题的约束不同。
传统优化问题
minimize obj1: 1/4 quarter time
obj2: 0-60mph time
s.t. rpm at any time <= red line
现在豪车柴油党关心的是解决这个新问题:
minimize obj1: 1/4 quarter time
obj2: 0-60mph time
s.t. rpm at any time <= 2000
o**y
发帖数: 1466
12
来自主题: Database版 - 问一个SQL LOADER BLOB的问题
Today I had a little progress in this problem. Here is my temporary solution:
1. In the client side, save all of the objects' BLOB bytes to one BIGBLOB
file, and have records like that in another separate file:
obj1, length 20, offset 1
obj2, length 500, offset 21
.....
then sql*loader 1) the records; 2) the BIGBLOB file to the server. The
content of BIGBLOB file is saved into another table (single row, BLOB field)
2. In the server side, then split the BIGBLOB into small chunks based on the
offs... 阅读全帖
c***c
发帖数: 6234
13
来自主题: Java版 - Help: web service questions
1. C++ can not call a Java Web Service which return an Object. Right? I have
to call a C++ described Web Service Right?
2. Is it possible that a method returns multiple parameters, such as
String Method (Class1 obj1, Class2 obj2, Class3 obj3)
obj2 and obj3 are empty and after I call Method(1,obj2,obj3), I get value back
Thanks
s*******e
发帖数: 28
14
来自主题: Programming版 - 一道面试怪题C++. (转载)

has
Think again about what?
With forward declarations, there is of course No need to include ".h" file.
class A; // no need to have #include "A.h"
class B
{
....
private:
A *obj1;
};
Note ".h" files contains only a bunch of forward declarations.
(共0页)