output of function using in other class

Hello, I have multiple classes. 2 of them are named ListPlayers and Player. Well you can see player more as a struct. It has the name of the player, the amount of money he still has (it's a poker game) also a previous and next, because I'm using doubly linked lists (this is needed as it is a school project). In the other class, ListPlayers, I keep track of how many players, I add them in a Doubly linked list, I add one human player and the player can choose against how many computer players, he want to play. Well now, my question. When I want to acccess all the players in a loop so I can deal the cards, I need to know to which player and how many. How many is generated in a function in ListPlayers, the function returns the integer. But when I call the function inside Player, it returns 0. It might be because I don't really understand want constructors are or when to use public or private memebers. Until this moment, everything works fine, so I guess I did everything right.
Well you can see player more as a struct

Why you do not make it actual struct?
I'm using doubly linked lists

You mean double ended lists, delists?

Constructors are special functions which have no return type and are called only once when the object is created(if you are using pointers, not sure how it goes if you have a static object/class.)
Private attributes can be accessed inside the class only. Public attributes can be accessed inside and outside. Usually, private attributes are variables, while public has all class methods. Sometimes you want to mix them up for various reasons, but that's the idea.
So, the function, which returns how many cards table players should receive, does not work?
Generally you want your class specific variables to be private. This keeps you or any other from accidentally altering it. You generally have setter and getter methods for these variables. Setters will alter it, and getters will retun the value.
Simply deducing from the fact that you don't get compiler errors I guess you are not trying to call a private class function member.

Define the relation between those 2 classes.
Do they know of each other? I mean is one of them defined inside the other? etc
How do you call this function member? You create an object of type ListPlayers inside Player?

And also sometimes it's really helpful posing some code. Not necessary the whole code just the parts needed to clarify what have you done and intend to do.
Topic archived. No new replies allowed.