This is a relatively simple question, but the specifics are confusing me.
I have a basic struct as follows:
struct player {
string name;
int rating;
};
and a class ‘team’ which would make use of this struct. With this in mind, where is the correct placement of the ‘player’ struct- inside the public/private fields of the team or in a separate file? Also, would there be anything different that I’d need to do in order to create an instance of it? Thanks.
It depends on the how you use team/player struct. If you player is used by other part of the application, you should put player independent, that’s the most cases do.
if your
Playeris totally internally used byTeamand no one is using it, you can put it insideTeamstruct/class to narrow down its name scope.