Any advice would be helpful. Since I am trying to abstract the class as much as possible I am not sure what extra information I can add at this point.
If you would like more context or if you have a question please ask.
The type of your private object next is 'Player *', so a pointer to a Player object. However, your function setNext has a object of type 'Player' as argument. You probably want this to be a pointer as well, or maybe a reference (so, Player const&)
You should understand the difference between:
1 2 3
Player player; // player is a object of type player.
Player other_player = player; // other_player is a NEW object, and a copy of the other object player.
Player* player_pointer = &player; // A pointer to the Player object player.
Lastly, there's also the possibility of passing function arguments as reference:
1 2 3 4 5 6 7 8
void setNext(Player const& player) {
this->next = &player;
}
// Called like this:
Player player;
Player another_player;
player.setNext(another_player);
However, I think you will probably want to understand normal pointers first. Your setNext function should probably have an argument of type Player*.
Good luck!
edit: Be careful with the last example: When another_player goes out of scope, the reference (next) will become invalid.
You probably shouldn't have those trivial set functions at all, use an initialiser list instead. You may not need the get functions either (possibly).
Think about what a player can do, write down these action words (verbs), that should give clues as to what functions you need. These will form the interface for your class.
Can you use std::string instead of char * ? I mean, do you have a particular reason to need char arrays?
Should you be using <iostream> instead of <stdio.h>
You probably shouldn't have those trivial set functions at all, use an initializer list instead. You may not need the get functions either (possibly).
@TheIdeasMan: you might be correct. I was/am writing the class very defensively because I am using it in a Hash Table that chains into a linked list for a data structures class, with a some restrictions on the interface. In other words I wanted to stay away from tweaking this class as much as possible when I started to work on my hash table. Also we are using char * as part of the exercise, so that is why I went by the rule of 5 just to prevent as many run-time debugging issues as possible.
Thank you for pointing out I should remove <stdio.h> I am using xCode at it plugs that into the header of all c++ classes. :)
@BasV Thank you for your guidance. I am clear on the differences you pointed out, I was just programming too long by the time I wrote this question and I had no idea what I was looking a by the time I was stuck. Thanks again for your help it was very helpful and exactly what I needed to know and be told!