I have a class Library, and it includes a member object shelf1 from another class Shelf.
The Class Shelf have several variables, say:
class Shelf {
int height;
int width;
int materialType;
String shelfName;
}
Now in Library, I want to initialize the member object shelf1 in the Library declaration:
Shelf shelf1{100, 200};
Shelf shelf2{100, "fiction"};
Can they work, and how List-initialization works for the order of variables?
[Update] Those code are for explanation of my question (I do have a similar code in my real world. But it is too complicated to put here. So I simplify my question).