Hello everyone.
I'm a fairly experinced java programmer, but to broaden my knowledge of programming in general i recently decided to learn c++ (or atleast to understand it).
Im doing alright on the semantic/syntatic part of it, but i have some trouble structuring my programs correctly - maybe because i think too much like a java programmer?
So, to be a little more specific i've been working on the logic for a
http://en.wikipedia.org/wiki/Connect_Four game.
I've decided on the classes:
Game: to represent the board
Brick:
Player: To represent the player in turn
Position: A struct to encapsulate lookups in the board
Resulting in class diagram looking like this:
http://i.imgur.com/hs6A1By.jpg
(The dependency arrows might have to be association arrows?)
Anyways, my question is now, how would i structure this in files? I've read that it's a good pratice to represent each class as a header file with declartions and a .cpp file with the full definition. Unless the class represents an interface/abstract class, then i only need to represent it with a header file?
That leaves me with the following list of files:
Headers:
Game.h
Game_class.h
Brick.h
Player.h
Player_class.h
Position.h
Cpp files:
Game_class.cpp
Brick.cpp
Player_class.cpp
Position.cpp
Now, for the sake of arguement, say that i decide to add an enumeration "Color", to distinguish the players and the bricks. This means that both Player and Brick have to implement the same header Color.h. And that i need a new file "just" to represent a simple enum? Is that really best pratice? I feel like a program made with that mindset could grow into the thousands of files fairly quickly?
Also i know that the interfaces are a little overkill in this example, but i need them to illustrate my point.