首页 > 编程知识 正文

构造函数怎么初始化,构造函数初始化列表

时间:2023-05-03 20:01:54 阅读:109149 作者:4338

I have this class constructor:

公共类别(intmax ) {

.

}

The thing is,I want to make an array of this class,how do I initialize it?

privatecategorycategories=new category (max ) [4];

订单不工作。

更新

Do I need to do something like this?

private category [ ] categories=new category [4];

And then initialize each object?

When you are making an array,youarecreatinganarrayofcategory.thatsaninstanceofarry。

whenyouarepopulatingthearraywithcategoryobjects,atthatpointyousethecategorywithconst。

category [ ] categories=new category [4];

categories[0]=newcategory(10 );

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。