title: c++ Accessing specific value in Single Linked List
body: <p>My list contains a name and a campus id(CWID). How can i compare the cwid that is in my list to the integer i am passing in? I wrote the psuedo code of the comparison below of what i am trying to do. </p>
  
  <pre><code>void check_cwid(studentList&amp; list, int cwid) {
  
  studentNode *p = list.head_;
  
  while(p != nullptr){
  
   //Something like this 
     if *p.cwid() == cwid
    //do something
  
    p = p-&gt;next_;
  
  }
  </code></pre>
  
  <p>I am trying to accomplish what is in the code above. I just dont know how to compare specific items in my list. Here is my entire practice project below.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class student {
  
  public:
  
      student(const string&amp; sname = "", int cwid = 0) : sname_(sname), cwid_(cwid) {}
  
      string sname() const {return sname_;}
      int cwid() const {return cwid_;}
  
      friend ostream&amp; operator &lt;&lt;(ostream&amp; os, student st){
          return os &lt;&lt; endl &lt;&lt; st.sname_ &lt;&lt; endl &lt;&lt; st.cwid_ &lt;&lt; endl;
      }
  
  
  
  private:
  
      string sname_;
      int cwid_;
  
  };
  
  
  struct studentNode {
  
      studentNode(const string&amp; sname, int cwid, studentNode* next=nullptr) :st_(sname, cwid), next_(next) {}
  
      studentNode(student&amp; st, studentNode* next=nullptr) : st_(st), next_(next) {}
  
      friend ostream&amp; operator &lt;&lt; (ostream&amp; os, studentNode node) {
          return os &lt;&lt; node.st_;
      }
  
  
      studentNode* next_;
      student st_;
  
  };
  
  struct studentList {
  
      studentList() : head_(nullptr), size_(0) {}
  
      studentNode* head_;
      size_t size_;
  
  };
  
  
  ///******************** what im trying to do
  void check_cwid(studentList&amp; list, int cwid) {
  
      studentNode *p = list.head_;
  
      while(p != nullptr){
  
  
  
  
      }
  }
  </code></pre>