是否为类中的数组执行了init? [英] Is init done for arrays in classes?
问题描述
B级{
// ...
public:
B(){/ * ... * /};
};
A级{
B b [100];
public:
A(){};
// ...
};
问题:是否在通话期间初始化了b的元素
A();
提前致谢
Alex。
PS。要给我发电子邮件,请删除loeschedies。从给出的电子邮件地址。
class B {
//...
public:
B() { /* ... */};
};
class A {
B b[100];
public:
A() { };
//...
};
Question: are the elements of b get initialized during the call
A();
Thanks in advance
Alex.
PS. To email me, remove "loeschedies" from the email address given.
推荐答案
Alexander Malkis写道:
Alexander Malkis wrote:
B类{
// .. 。
公开:
B(){/ * ... * /};
最后一个分号是多余的,即使它不是错误。
};
A类{
B b [100];
公开:
A(){};
同样在这里。
// ...
};
问题:是b获取的元素在通话过程中初始化
A();
class B {
//...
public:
B() { /* ... */};
The last semicolon is superfluous, even though it is not an error.
};
class A {
B b[100];
public:
A() { };
Same here.
//...
};
Question: are the elements of b get initialized during the call
A();
是的。 (假设我理解你的意思是电话
A();)
-
祝你好运,
Andrey Tarasevich
Yes. (Assuming that I understand correctly what you mean under "the call
A();")
--
Best regards,
Andrey Tarasevich
2004年5月18日星期二18:50:36 +0200,Alexander Malkis
< al ***************** @ stone.cs.uni-sb.de>写道:
On Tue, 18 May 2004 18:50:36 +0200, Alexander Malkis
<al*****************@stone.cs.uni-sb.de> wrote:
B类{
// ...
公开:
B(){/ * ... * /};
};
A类{
B b [100];
公开:
A(){};
// .. 。
};
问题:b的元素是在调用过程中初始化的
A();
提前致谢
亚历克斯。
轻微改写:
#include< iostream>
使用命名空间std;
B级{
// ...
公开:
B(){std :: cout< ;< B(); }
};
A级{
B b [100];
public:
A(){std :: cout<< " A()英寸; }
// ...
};
int main()
{
A a;
返回0;
}
输出:
B()B()B()B()B()B()B()B()B()B()B()B()B()B()B()B() B()B()B()
B()B()B()B()B()
B()B()B()B ()B()B()B()B()B()B()B()B()B()B()B()B()B()B()B()>
B()B()B()B()B()
B()B()B()B()B()B()B()B ()B()B()B()B()B()B()B()B()B()B()B()
B()B()B ()B()B()
B()B()B()B()B()B()B()B()B()B()B()B ()B()B()B()B()B()B()B()
B()B()B()B()B()
B()B()B()B()A()
回答你的问题? ;-)
-leor
PS。要给我发电子邮件,请删除loeschedies。来自给出的电子邮件地址。
class B {
//...
public:
B() { /* ... */};
};
class A {
B b[100];
public:
A() { };
//...
};
Question: are the elements of b get initialized during the call
A();
Thanks in advance
Alex.
Slight rewrite:
#include <iostream>
using namespace std;
class B {
//...
public:
B() { std::cout << "B() "; }
};
class A {
B b[100];
public:
A() { std::cout << "A()"; }
//...
};
int main()
{
A a;
return 0;
}
Output:
B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B()
B() B() B() B() B()
B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B()
B() B() B() B() B()
B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B()
B() B() B() B() B()
B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B() B()
B() B() B() B() B()
B() B() B() B() A()
Answer your question? ;-)
-leor
PS. To email me, remove "loeschedies" from the email address given.
-
Leor Zolman --- BD软件--- www.bdsoft.com
C / C ++,Java,Perl和Unix的现场培训
C ++用户:下载BD Software的免费STL错误消息解密器:
www.bdsoft.com/tools/stlfilt.html
Alexander Malkis写道:
Alexander Malkis wrote:
B班{
// ...
公开:
B(){/ * ... * /};
};
A级{
B b [100];
公开:
A(){};
// ...
};
A();
class B {
//...
public:
B() { /* ... */};
};
class A {
B b[100];
public:
A() { };
//...
};
Question: are the elements of b get initialized during the call
A();
12.6.2 / 4表示自''B' '是非POD类,它是默认初始化的。
V
12.6.2/4 says that since ''B'' is a non-POD class, it''s default-initialised.
V
这篇关于是否为类中的数组执行了init?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!