title: struct or class and what about public data?
body: <p>When it comes to creating classes I've been told NO public data members.  That's fine and I understand why but here's my issue.  I've got a struct that I am using in a class (Linear linked list).  I'd really like to initialize one of the struct fields (an array) to NULL so that I can check that the client is passing me valid structs, not uninitalized one's that are full of garbage values.  I realize c++ won't let me set a default value in the struct declaration, so how do I protect from the client giving me garbage?  </p>
  
  <pre><code>struct task {
      char *description;
      char *name;
      float time_remaining;
      float time_spent;
  };
  </code></pre>
  
  <p>Then in my class I'm trying to do something like:</p>
  
  <pre><code>//I am making a copy of "to_add" and storing it in the LLL
  int list::add_to_list(const task &amp; to_add)
  { /.../ }
  </code></pre>
  
  <p>I don't want the user adding a bunch of uninitialized "task's" to the linked list...  What to do?  When I turned that struct into a class and moved the data members to private I had a TON of issues trying to access the data members to make copies of them.  I was very careful not to do anything to effect the value of the var's but I couldn't get away from the compiler giving me errors about "error: passing ‘const task’ as ‘this’ argument of ‘char* task::get_comp_name()’ discards qualifiers [-fpermissive]" ("get_comp_name") was one of the getter's that I was sure wasn't editing any values, just passing me a copy) Please help me before I shoot myself.  In the face.</p>