Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's go through line-by-line:</p> <pre><code>#ifndef PLAYER_H #define PLAYER_H #include "utility.h" </code></pre> <p>So far so good, you might check if your compiler supports <code>#pragma once</code>, but the macro will work perfectly fine.</p> <pre><code>class Player() </code></pre> <p><code>()</code> aren't allowed in a class name, take them off</p> <pre><code>{ public: //getPlayerID(); }; #endif </code></pre> <p>The rest of the header file is ok. Let's look at the implementation file:</p> <pre><code>#include "player.h" </code></pre> <p>Perfect. Putting a class in a header is the best way to make sure you only have one definition used in your whole program.</p> <pre><code>class Player() </code></pre> <p>Parentheses aren't allowed, but here you have a bigger problem. You already have a class with that name. Let the header provide the class definition, the implementation file just needs to provide the non-inline member functions (and any helper code).</p> <pre><code>{ string playerID; int timeCycle; } </code></pre> <p>Here's a complete corrected version:</p> <pre><code>#if !defined(PLAYER_H) #define PLAYER_H #include &lt;string&gt; #include "utility.h" class Player { std::string player_id; int time_cycle; public: // this is how you make a constructor, the parenthesis belong here, not on the class name Player(std::string id, int time); std::string getPlayerId() const; }; #endif /* !defined(PLAYER_H) */ </code></pre> <p>and implementation file</p> <pre><code>#include "player.h" // and this is how you write a non-inline constructor Player::Player(std::string id, int time) : player_id(id) , time_cycle(time) {} std::string Player::getPlayerId() const { return player_id; } </code></pre> <p>All of these problems are really basic C++ stuff, nothing to do with NachOS.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload