看一下程序
#include <stdio.h>
typedef unsigned long int UINT4;
typedef struct {
UINT4 state[4];
UINT4 count[2];
} MY_T;
void initByPoint (MY_T *context)
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
*/
context->state[0] = 1;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
void initByRef (MY_T &context)
{
context.count[0] = context.count[1] = 0;
/* Load magic initialization constants.
*/
context.state[0] = 2;
context.state[1] = 0xefcdab89;
context.state[2] = 0x98badcfe;
context.state[3] = 0x10325476;
}
void initByCommon (MY_T context)
{
context.count[0] = context.count[1] = 0;
/* Load magic initialization constants.
*/
context.state[0] = 3;
context.state[1] = 0xefcdab89;
context.state[2] = 0x98badcfe;
context.state[3] = 0x10325476;
}
int main(){
MY_T t;
MY_T &r=t;
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
initByCommon(t);
//initByCommon(r); 结果一样
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
initByPoint(&t);
//initByPoint(&r);结果一样
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
initByRef(t);
//initByRef(r); 结果一样
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
return 1;
}
t.state[0]=3218421528
r.state[0]=3218421528
t.state[0]=3218421528
r.state[0]=3218421528
t.state[0]=1
r.state[0]=1
t.state[0]=2
r.state[0]=2
elemtype& a1;
elemtype *a2;
elemtype a3;
fun1(elemtype& a);
fun2(elemtype *a);
fun3(elemtype a);
请问a1,a2,a3分别能做为fun1,fun2,fun3中哪几个函数的参数?
a1-f1,f3
a2-f2
a3-f1,f3
#include <stdio.h>
typedef unsigned long int UINT4;
typedef struct {
UINT4 state[4];
UINT4 count[2];
} MY_T;
void initByPoint (MY_T *context)
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
*/
context->state[0] = 1;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
void initByRef (MY_T &context)
{
context.count[0] = context.count[1] = 0;
/* Load magic initialization constants.
*/
context.state[0] = 2;
context.state[1] = 0xefcdab89;
context.state[2] = 0x98badcfe;
context.state[3] = 0x10325476;
}
void initByCommon (MY_T context)
{
context.count[0] = context.count[1] = 0;
/* Load magic initialization constants.
*/
context.state[0] = 3;
context.state[1] = 0xefcdab89;
context.state[2] = 0x98badcfe;
context.state[3] = 0x10325476;
}
int main(){
MY_T t;
MY_T &r=t;
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
initByCommon(t);
//initByCommon(r); 结果一样
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
initByPoint(&t);
//initByPoint(&r);结果一样
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
initByRef(t);
//initByRef(r); 结果一样
printf("t.state[0]=%lu\n",t.state[0]);
printf("r.state[0]=%lu\n",r.state[0]);
return 1;
}
t.state[0]=3218421528
r.state[0]=3218421528
t.state[0]=3218421528
r.state[0]=3218421528
t.state[0]=1
r.state[0]=1
t.state[0]=2
r.state[0]=2
elemtype& a1;
elemtype *a2;
elemtype a3;
fun1(elemtype& a);
fun2(elemtype *a);
fun3(elemtype a);
请问a1,a2,a3分别能做为fun1,fun2,fun3中哪几个函数的参数?
a1-f1,f3
a2-f2
a3-f1,f3