比方說,我們有一個框類:自動選擇和創建類對象
class Box
{
private int width;
private int height;
//Box Constructor
public Box(int height)
{
this.height = height;
width = 450;
}
}
,並在一系列框對象我們的主要:
Box Box1 = new Box(147);
Box Box2 = new Box(178);
Box Box3 = new Box(784);
是否有使用「的方式爲「循環通過這些對象?另外,你將如何讓計算機爲我們創建類對象? 例如。創建10個對象使用:
for(int i=0; i>10; i++)
{
//method
}
C++的標籤是不相關的。 – chris
選擇一種語言並學習使用它提供的容器。 – undu
C++標記已被刪除。 –