由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - c++:constructor 一问
相关主题
c++ initialize structc++ 一问
c++标准函数传递一问Is the order of initialization a, b, c or c, b, a?
关于数组动态分配的疑问???one question about initializaiton list
Test your C++ knowledge...a simple question about constructor
几个问题一道 memset in C++的题
问一个 copy constructor 的问题 (C++)what is the difference?
question about c++ constructorstatic initialization dependency c++
operator() overloading 一问How to initialize object in constructor?
相关话题的讨论汇总
话题: arraya话题: class话题: default话题: 一问
进入Programming版参与讨论
1 (共1页)
yy
发帖数: 45
1
请问
如果一个class A 没有定义任何的constructor,
A arrayA[10]; will be legal, for each element, will be initialized with
the compiler's default constructor.
如果 class A, 定义了一个 constructor like:
A(int number);
则: A arrayA[10]; will be illega since there lack of a default consturctor.
请问, 我得理解对吗?
谢谢
c********e
发帖数: 383
2
right, you could do
A arrayA[10] = {A(2), A(2)...};

【在 yy 的大作中提到】
: 请问
: 如果一个class A 没有定义任何的constructor,
: A arrayA[10]; will be legal, for each element, will be initialized with
: the compiler's default constructor.
: 如果 class A, 定义了一个 constructor like:
: A(int number);
: 则: A arrayA[10]; will be illega since there lack of a default consturctor.
: 请问, 我得理解对吗?
: 谢谢

1 (共1页)
进入Programming版参与讨论
相关主题
How to initialize object in constructor?几个问题
抠字眼:assignment and initialize in C++问一个 copy constructor 的问题 (C++)
大家谈谈看??question about c++ constructor
pthread_create inside a constructoroperator() overloading 一问
c++ initialize structc++ 一问
c++标准函数传递一问Is the order of initialization a, b, c or c, b, a?
关于数组动态分配的疑问???one question about initializaiton list
Test your C++ knowledge...a simple question about constructor
相关话题的讨论汇总
话题: arraya话题: class话题: default话题: 一问