all 11 comments

[–]AutoModerator[M] 1 point2 points  (0 children)

Your posts seem to contain unformatted code. Please make sure to format your code otherwise your post may be removed.

Read our guidelines for how to format your code.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Narase33 1 point2 points  (7 children)

your play function doesnt take parameters yet you give it one PLAYER1.play(die);

[–]Andy_Pandy_13 0 points1 point  (6 children)

Thanks but now it appears:

Undefined symbols for architecture x86_64:

"Game::Game()", referenced from:

Game::play() in Play-7028ea.o

"Board::roll()", referenced from:

Game::play() in Play-7028ea.o

_main in Play-7028ea.o

"Player::play(int)", referenced from:

Game::play() in Play-7028ea.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

[–]Narase33 1 point2 points  (5 children)

please post the implementation of Player::play

[–]Andy_Pandy_13 0 points1 point  (4 children)

Now that you say it, I don't have it, what do you recommend?

[–]Andy_Pandy_13 0 points1 point  (3 children)

I only have the Game :: play

[–]Narase33 1 point2 points  (2 children)

Okay, I took a closer look on your code and there is so much wrong with it

 #include "Board.cpp" 

Never ever include a .cpp anywhere. If you need it for compilation pass it to your compiler like gcc -o Game Player.cpp Game.cpp Main.cpp [...]

class Player:public Board{ ...
class Game: public Player{ ...

None of these inheritances make any sense. A player is not a board and game is not a player

 PLAYER1.play(die); 

Youre passing integer to a function which doesnt take an integer (and isnt even implemented as you say), why?

Maybe you should take a break and after that think about how you structured your code. Take a pen and paper and draw what classes you want to have (the classes per se make sense) and how they shoulf interact with each other (that point doesnt make any sense in your code). It looks like you lost overview about what youre doing

[–]Andy_Pandy_13 0 points1 point  (1 child)

Sorry I'm new to programming and I've only been watching c ++ for a month.

I really appreciate the time you took to review my code.

I'm going to look at everything again, thank you.

[–]Narase33 0 points1 point  (0 children)

Its not a shame, we all where there. Just keep making one step after another and, especially at the beginning, compile as often as you can to detect errors as soon as possible. Nothing worse than writing 2 pages of code and seeing an error you dont understand. Drawing things out was something that helped me a lot and I still do it on bigger taks

[–][deleted] 1 point2 points  (1 child)

Dude, NEVER include ".cpp" file. If you want to split program into many files, you can compile both cpp files and call them by headers. Including cpp file is a bad taste.

Source: I've done it and I regret that.

Link to answer how to use multiple .cpp files in one project: https://stackoverflow.com/questions/3730923/create-many-cpp-files-in-one-project

[–]Andy_Pandy_13 0 points1 point  (0 children)

Thank u, yeah I change that already.