由买买提看人间百态

topics

全部话题 - 话题: function1
(共0页)
W***o
发帖数: 6519
1
跟各位请教一下 这个makecontext() 函数,比如我有下面的代码:
ucontext_t ctx_a;
void function1()
{
// do something
printf("this is the output of function1()");
}
makecontext(&ctx_a, (void*)&function1, 0);
这个makecontext是永远的把function1()函数附加在context ctx_a上了吗? 如果是这
样的话,在Main() 里面做swapcontext(&Main, &ctx_a) 就还是会显示function1() 的
output对不对?
我写了code,似乎我这种想法是正确的,只是想和这里的高手确认一下。谢谢
n*****t
发帖数: 22014
2
makecontext will call function1,also you dont need put & in front of
function1
h***i
发帖数: 3844
3
来自主题: Statistics版 - R 循环问题
比如有循环
i<-0
while(i<=100){
function1...
i<-i+1;
}
function1有时候会出错,R 就自动stop了,
如何能够实现让R在function1有错的时候自动跳过,
比如
i<-0
while(i<=100){
if(function1 有错){i 不变}
else {function1...; i<-i+1}
}
r****o
发帖数: 1950
4
来自主题: JobHunting版 - 问一个精华区里的题目
刚才试了一下,两个const按存在不存在取4种组合,函数都能正确工作,除了一些
warning以外。
const char *function1(void)
{
const char *s = "12345";
return s;
}
const char *function2(void)
{
char *s = "12345";
return s;
}
char *function1(void)
{
const char *s = "12345";
return s;
}
char *function1(void)
{
char *s = "12345";
return s;
}
是不是这4个函数等价?
f*******r
发帖数: 1086
5
来自主题: JobHunting版 - 问一个精华区里的题目
Great answer:)
const char *function1(void)
{
const char *s = "12345";
return s;
}
the function1 should be like this.
c**y
发帖数: 172
6
函数声明如下
void function1(const char *a) {
...
...
return;
}
如何能在函数function1中访问a呢?我只想到用strcpy的方法把a复制到另外一个char
array中。有没有什么办法直接访问a,而不使用额外的内存?
c*****e
发帖数: 34
7
来自主题: Programming版 - 问个static member function的问题
一个class,没有member variable,只有static member function.
我发现这些static member function 可以用来改变global variable的值.打个比方:
int main() {
int m=0;
classname::function1(m);
}
这个 function1 可以改变m的值,虽然不是pass by reference.我觉得比较奇怪,是不是
static member function就有这种用法?
谢谢大家!
s*******e
发帖数: 664
8
☆─────────────────────────────────────☆
ttgg (暂时没有昵称) 于 (Fri Jun 26 17:02:17 2009, 美东) 提到:
请教如下C++代码(左边的数字是行号)
为了使用polymorphism的动态榜定
基类函数被定义成virtual
然后子类里不同的实现
这个我能明白
可是问题是
在有些例子里
子类的对应函数同样被加上了virtual关键字,
请问这是为什么?
我看了网上资料
如果基类里有virtual函数
那么这个类的object就会包含virtual table
而它的所有子类obj也自动包含v-table
所以为什么还要加上virtual修饰呢?
01.class Base
02.{
03.public:
04. virtual void function1() {};
05. virtual void function2() {};
06.};
07.
08.class D1: public Base
09.{
10.public:
11. virtual void function1(
h**o
发帖数: 548
9
来自主题: Programming版 - c 语言 查 memory
I do not care heap or stack. I just want to know how much more RAM is used
after I call some malloc() in function1(). I work on Solaris OS using C
lauguage. The prstat does not give the accurate amount and besides, I want
to know how much more memory is consumed each time after function1() is
called.
p*****2
发帖数: 21240
10
来自主题: Programming版 - 如何定义 Javascript overload function ?
这样行不行?
f1.js 定义 function1
f2.js 定义 function2
f.js 根据config export function1 or function2
f****4
发帖数: 1359
11
来自主题: JobHunting版 - 问一个精华区里的题目
Explain the difference between the following two functions, highlight any
perceived problems, and state which one is the preferred implementation and
why it is preferred.
char *function1(void)
{
char *s = "12345";
return s;
}
char *function2(void)
{
char s[MAX_STRLEN] = "12345";
return s;
}
这有啥区别啊?
L*******e
发帖数: 114
12
来自主题: JobHunting版 - Embrassed Bloomberg 电面
一点废话都没有,全是technical的东西,我实在太水了。
1. what happended after you type shell command in Linux?
2. what is the reason that shell hangs?
3. what is SIGCHILD and how to use it? how the parent process collect status
of child?
4. what is dynamic_cast? give a scenario that requires dynamic_cast? how
dynamic_cast is implmented?
5. What is the issue for the following program?
int main()
{
Foo *p = new Foo(1);
p->function1();
return 0;
}
Suppose Foo is defined already. I said the me... 阅读全帖
e****e
发帖数: 1885
13
接近年末,公司最近老中马公来面的有点多,我是考得郁闷,他们也面的郁闷。这不刚
刚又面了一个老中,写了会儿review,憋的不行。有些话实在是憋在心里郁闷,上来发
几句感言
1. 最近,这些来面试的码农,一眼看上去,无论之前是不是也是干软件的,一眼看上
去各个都是leetcode答案烂熟于胸的。咱老中干什么都有个优点,就是勤奋,可是你刷
题就算再辛苦,准备了好几个月,搞定了几百道题,可是刷题真的不是背单词,拿出靠
GRE的劲儿可以,但是你方法不要也用“杨鹏17天”啊,只记标准答案,稍微有些变通
,甚至是往简单的地方改,你就原封不动把leetcode上的数据结构往上套啊。变通,懂
吗?变通!
2. 我个人觉得,leetcode开始打算盈利后,就有点儿走火入魔了,搞得题目那么多,
弄的重点不突出。搞得大家只focus在数量上了,但是对基本的概念都不重视。刷的再
多,但是一旦遇到没见过的题目,哪怕是最简单的easy难度,只是原题稍微变动一下
的,基本的数据结构做些微调都搞不定。一击不中,原题解法不 work,就开始乱猜,
什么乱七八糟的名词数据结构就开始生搬硬套往上凑。这不是坑自己嘛,就是算是... 阅读全帖
k******8
发帖数: 325
14
来自主题: Seattle版 - 我喜欢WP7的search button
这么说手机的按钮也应该设计成这样的,按-function1,拧着按-function2
g***l
发帖数: 352
15
来自主题: CS版 - [转载] latex question
【 以下文字转载自 EE 讨论区,原文如下 】
发信人: gbull (BULL), 信区: EE
标 题: latex question
发信站: Unknown Space - 未名空间 (Mon Jan 3 00:29:53 2005) WWW-POST
How to input algorithm by using latex?
For example, the follow code:
function1(int x){
if (x > 10){
do something;
else
return;
}
Thanks a lot.
C******e
发帖数: 1850
16
来自主题: Programming版 - 请教一个文件IO的问题
请教大侠们一个文件IO的问题,我有一段程序要读出一个文件里的数据进行处理,但由
于文件很长,
所以想用一个CALLBACK函数专门来分批的读文件,每次读一段。主程序处理完了现有的
数据,就让
CALLBACK去读下一块。思想如下:
int callback(int **databuf, void* userdata)
{
state = userdata;
fseek(state->fp, OFFSET, 0);
r = fread();
return r;
}
main()
{
declare userdata;
userdata.fp = fopen("file","r");
datastruct = function1(par1, par2, ..., &callback);
for(;;)
dataprocess(datastruct);
fclose(userdata.fp);
}
但是好像不对,一运行就死了,请大侠指正。多谢了。
h**o
发帖数: 548
17
来自主题: Programming版 - c 语言 查 memory
我想实现这个功能:
function1()
{
....
m1 = get the current physical memory;
....
m2 = get the current physical memory;
get the difference between m1 and m2;
}
也就是说我想算m1, m2 之间 程序用了多少memory.
请问如何得到当前的memory 哪?
y****I
发帖数: 86
18
来自主题: Quant版 - ok, not so short phone interview
my first one and I think I screwed it. (with GS)
anyway, they told me that's 30 minutes, but it took 55 minutes instead.
two questions I didn't get:
1.
void function1(const TestClass& iclass)
}
}
what if you want to change some fields in iclass with the same interface?
2. I should have got this one, but ...
what else need to be considered in the overloaded assignment operator
compared with copy constructor.
got the answer after his hint.
B*********h
发帖数: 800
19
☆─────────────────────────────────────☆
yogaII (...) 于 (Fri Jan 12 16:01:09 2007) 提到:
my first one and I think I screwed it. (with GS)
anyway, they told me that's 30 minutes, but it took 55 minutes instead.
two questions I didn't get:
1.
void function1(const TestClass& iclass)
}
}
what if you want to change some fields in iclass with the same interface?
2. I should have got this one, but ...
what else need to be considered in the overloaded assignment operator
compared with copy constructor
a***r
发帖数: 420
20
来自主题: Statistics版 - 请教一个log scale的运算
啊,是我原帖没说清楚
其实temp=function1(i)*function2(i)
两个都小到1e-200左右这种级别,乘起来就被ignore了
log之后基本能都被挽救
(共0页)