问题的大小(面试问题) [英] Sizeof problems(interview questions)

查看:87
本文介绍了问题的大小(面试问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



A级

{

int a;

};

cout<<"A的大小是<<< sizeof(A)<< endl;


问:结果是什么?


现在添加一个函数,int getVal( );


现在的结果是什么?


解释原因


Class A
{
int a;
};

cout<<"the size of A is "<< sizeof(A)<<endl;

Q: what is the result?

Now Add in a function, int getVal();

What''s the result now?

Explain why

推荐答案

ma****@gmail.com 写道:
A级
{
int a;
};


语法错误。什么是阶级? (''class'',我们知道; C ++区分大小写。)
cout<<"A的大小是<<的sizeof(A)<< ENDL;


假设上面已正确声明'A'',答案是

`无论sizeof(A)*表示*它是什么。
问:结果是什么?

现在添加一个函数,int getVal();

现在的结果是什么?


同样。

解释为什么
Class A
{
int a;
};
Syntax error. What is `Class''? (''class'', we know; C++ is case sensitive.)
cout<<"the size of A is "<< sizeof(A)<<endl;
Assuming that `A'' has been declared correctly above, the answer is
`whatever sizeof(A) *says* it is.
Q: what is the result?

Now Add in a function, int getVal();

What''s the result now?
Similarly.

Explain why



因为做自己的功课就是所谓的,不是作弊。


- g


-

Artie Gold - 德克萨斯州奥斯汀
http://it-matters.blogspot.com (新帖子12/5)
http://www.cafepress.com/goldsays


Because doing your own homework is something called, well, not cheating.

--ag

--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays


2005年7月7日18:25:02 -0700, ma **** @ gmail.com 在comp.lang.c ++中写道:
On 7 Jul 2005 18:25:02 -0700, ma****@gmail.com wrote in comp.lang.c++:

A类
{
int a;
};
<<<"" A的大小是<<<< sizeof(A)<< endl;

问:结果如何?


你回答了什么? C ++语言提供的唯一答案是
,sizeof(A)大于或等于sizeof(int)。在

数字,1或更大。

现在添加一个函数,int getVal();

现在的结果是什么?


第一个问题的答案对于第二个问题同样准确,

仍然> = sizeof(int),仍然> = 1.

解释原因

Class A
{
int a;
};

cout<<"the size of A is "<< sizeof(A)<<endl;

Q: what is the result?
What did you answer? The only answer that the C++ language provides
is that sizeof(A) is greater than or equal to sizeof(int). In
numbers, 1 or greater.
Now Add in a function, int getVal();

What''s the result now?
The answer to the first question is equally accurate for the second,
still >= sizeof(int), still >= 1.
Explain why




因为。进一步的解释毫无意义,因为试图给人留下深刻的印象

无论是谁想出这个作为一个有用的问题。


-

Jack Klein

主页: http://JK-Technology.Com

常见问题解答

comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html

comp.lang.c ++ http://www.parashift.com/c++-faq-lite/

alt.comp.lang.learn.c-c ++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html



Because. Further explanation is pointless, as is trying to impress
whoever it is came up with this as a useful question.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html


加油。我正在为人们提供一个练习/讨论的问题,而不是

为自己寻求答案。


如果你有信心,那就给你答案吧嘲笑

人。

Come on. I am providing a question for people to practise/discuss, not
asking for the answer for myself.

If you feel confident, just give your answer instead of laughing at
people.


这篇关于问题的大小(面试问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆