Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Why use [,] for initialization and () for assignment? Where value and suit are enumeration variables.
Why use [,] for initialization and () for assignment? Where value and suit are enumeration variables.
Assignment is also done with [,]. For example, this.cardpack [(int) suit, (int) value] = new playing card (suit, value);

This is not. cardpack [(int) suit,(int) value] just [,]? As for the new cards (color, value);

This is a constructor of the PlayingCard class. In parentheses are the parameters of this constructor. So use parentheses.

As for why it can't be changed to this. cardpack [(int) suit, (int) value] = new card cardsuit, value;

Huh?

Because when instantiating a class, there is no need to give the instance a specific value, so there is no need for a constructor. In the program body, if you want to use this instance, that is. CardPack[(int)suit, (int)value], you must give it an initial value, which means using a constructor. So it's not impossible to change.