'#pragma once' is by no means bad practice, but it is non-standard, and unrecognised #pragma statements tend to be ignored rather than flagged, so it would be possible to write code that worked on one preprocessor/compiler/linker chain and not another; of course, you'd get a bunch of errors from multiple includes and discover the unsupported #pragma, so it wouldn't be catastrophic.
I don't think the problem is with his header being included multiple times. It appears to me that the issue is that he is instantiating the player objects p1, p2, p3, etc. within the header file. It's hard to tell without seeing the other files as well and what is included. I don't see a "main", so this is apparently not the only file in the program.
Instantiating objects in a header file isn't forbidden, it's just (very) bad practice and would only be a problem if the header were included multiple times. I wonder if there are error messages about redefinition of existing objects p1, p2, p3... as well, tucked away in the error messages list.
We certainly could do with seeing the rest of the code and all the error messages.
If the objects were instantiated in a header file and the header file included in two or more *.c or *.cpp files, then the linker would complain about duplicate declarations, not "redefinition of 'class player'". That's why its more likely a problem with missing header guards, or the class is in fact declared multiple times in the same header and/or *.cpp file. Even lack of header guards would not be a problem is the header file is included only once in the same *.cpp file.
Now when I do it, it stops giving me the errors about defining the class multiple times.
However, it gives me errors about the instances being defined twice or "Multiple times" in the code... I definitely didn't define it twice.
Another thing is that it mentions some things in the *.o files (for main.cpp, board.cpp, and player.cpp). Is that normal. I've never seen it before.
If it's throwing errors related to *.o files, they're probably LINKER errors, not COMPILER errors, but we really can't say.
You must post relevant code and error messages when requesting assistance. Without them, everything we post is educated guesses and conjecture. It may be close, or it may be "out in Left-Field". Please post the details of the errors, and the relevant code.
Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...