title: C++ Best way to allow user to declare a struct object?
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  struct player
  {
    string name;
    int money = 100;
    int wins = 0;
  };
  
  int main()
  {
    string user;
    cin &gt;&gt; user;
    player user;
    user.name = user;
  }
  </code></pre>
  <p>What is the proper syntax for this in C++? I'm trying to declare the object name as the one given by the user. How would you do this? Would a class be easier to do this? Any tips/advice is much appreciated!</p>