Passing a class object into a template function. C++
<p>I have a template function defined as follows:</p>

<pre><code>template&lt;class T&gt;
string toString(T value) {

     ostringstream ss;

     if (is_same&lt;T, Student&gt;::value) {
         ss &lt;&lt; value.getFirst() &lt;&lt; ":" &lt;&lt; value.getLast() &lt;&lt; ":" &lt;&lt; value.getId() &lt;&lt; ":" &lt;&lt; value.getGpa();
         return ss.str();
     }

     else {
         //ss &lt;&lt; value;
         return ss.str();
     }
}
</code></pre>

<p>If i were to call this function like so:</p>

<pre><code>int main(){

      Student studentObj;
      toString(studentObj);

}
</code></pre>

<p>How do i access this classes various members from the toString function?</p>

<p>I have tried (errors commented)</p>

<pre><code>value.getId() //Returns int 
//Error C2228 left of '.getId' must have class/struct/union 
</code></pre>

<p>and</p>

<pre><code>value&lt;Student&gt;.getId()
//Error C2275 'Student': illegal use of this type as an expression  
</code></pre>

<p>Thanks in advance!</p>

<p>edit: Class definition</p>

<pre><code>class Student {
protected:
    std::string firstname;
    std::string lastname;
    int id;
    float gpa;
public:
    Student();
    Student(std::string, std::string, int, float);
    Student(const Student &amp;);
    std::string getFirst();
    std::string getLast();
    int getId();
    float getGpa();
};
</code></pre>